How to log a JavaScript object in the console
Learn, how to log a JavaScript object in the console.
To log or show a JavaScript object in the console, we can use the console.log()
method by passing the object as a second argument to it.
Here is an example:
const user = {
id:1,
name: "king"
}
console.log(`This is user object`, user); // correct way
Output:
This is user object {id: 1, name: "king"}