Yes, we can use a new line using “\n” in console.log(). Following is the code −
Example
const studentDetailsObject = new Object() studentDetailsObject.name = 'David' studentDetailsObject.subjectName = 'JavaScript' studentDetailsObject.countryName = 'US' studentDetailsObject.print = function(){ console.log('hello David'); } console.log("studentObject", "\n", studentDetailsObject);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo170.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo170.js studentObject { name: 'David', subjectName: 'JavaScript', countryName: 'US', print: [Function] }