FrontendDeveloper.in

JavaScript Track Detail

What is the purpose of dir method of console object

The console.dir() is used to display an interactive list of the properties of the specified JavaScript object as JSON.

const user = { name: "John", id: 1, city: "Delhi" };
console.dir(user);

The user object displayed in JSON representation Screenshot