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!
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"}
you can use
console.log(note, obj);
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()))