Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
How to console.log an object definition and a text in same string?

I have this JavaScript code:

console.log(obj);// [query: "wordOfTheDay"]
console.log(note + " : " + obj ); // obj does not show up

I want to make "obj" display in the same string as "note" no matter the type it come in as.

For example:

console.log("text sample : " + obj ); // text sample : [query: "wordOfTheDay"]

Thank you!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

console.log accepts any number of parameters, so just send each piece as its own param. That way you keep the formatting of the object in the console, and its all on one entry.

var obj = {
    query:  'wordOfTheDay',
    title:  'Frog',
    url:    '/img/picture.jpg'
};

console.log( "Text Here", obj);

// Text Here Object {query: "wordOfTheDay", title: "Frog", url: "/img/picture.jpg"}

over 4 years ago · Santiago Trujillo Report

0

you can use

console.log(note, obj);
over 4 years ago · Santiago Trujillo Report

0

console.log can take arbitrary number of arguments so you can put all data you need to log separating it by commas.

console.log("text sample : ", obj, JSON.stringify(obj), (typeof obj), (new Date()))
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!