node js console log object
const myObject = {
name: 'John',
age: 30,
city: 'New York'
};
console.log('My Object:', myObject);
Declare a constant variable
myObject
and assign it an object with three key-value pairs:name
with the value'John'
,age
with the value30
, andcity
with the value'New York'
.Use
console.log
to print a message and the content of themyObject
variable to the console. The message is a string literal:'My Object:'
, followed by the value ofmyObject
.