by @saigowthamr

How to log a JavaScript object in the console

Home » javascript » How to log a JavaScript object in the console

To display a JavaScript object in the console we need to pass an object as a second argument to the console.log() method.

const obj = {
    id:1,
    name: "king"
}

console.log(`This is king`, obj); // correct way

Output:

This is king {id: 1, name: "king"}