Ans: The console.log() is a function that prints a message to log on to the debugging console.
Q2: How do I iterate through a JSON object?
Ans: You can either use Object.values() or Object. entries(). It will return an array which we can then iterate over.
Q3: How do you turn an object into an array?
Ans: You can use one of the three methods to convert a object into an array:
Object.keys() , Object.values() , and Object.entries() .
Q4: What is the JSON format?
Ans: JSON (JavaScript Object Notation) is a standard text-based format used to represent structured data based on JavaScript object syntax.
Key takeaways
Today, we learned how to log an object in Node.JS. You can simply use console.log(object) up to two levels of nesting, but after that, it prints [Object] as a placeholder.
To avoid this problem, we saw that we could use any of these two methods:
JSON.stringify()
Use util.inspect()
We learned that the first one is a better method because, in the second method, nested objects got flattered after two levels.