Displaying Objects
Master this topic with zero to advance depth.
Expert Answer & Key Takeaways
Mastering Displaying Objects is essential for high-fidelity technical architecture and senior engineering roles in 2026.
JavaScript Object Display
How to display a JavaScript object? Displaying a JavaScript object will output
[object Object] if you try to print it as a string.1. Displaying Object Properties
The properties of an object can be displayed as a string:
const person = {name: "John", age: 30, city: "New York"};
console.log(person.name + ", " + person.age + ", " + person.city);2. Displaying the Object in a Loop
The properties of an object can be collected in a loop:
let text = "";
for (let x in person) {
text += person[x] + " ";
}3. Using Object.values()
Any JavaScript object can be converted to an array using
Object.values():const person = {name: "John", age: 30, city: "New York"};
const myArray = Object.values(person);
// myArray becomes ["John", 30, "New York"]4. Using JSON.stringify()
Any JavaScript object can be stringified (converted to a string) with the JavaScript function
JSON.stringify():const person = {name: "John", age: 30, city: "New York"};
let myString = JSON.stringify(person);
// myString is now a string: '{"name":"John","age":30,"city":"New York"}'[!IMPORTANT]JSON.stringify()will NOT stringify functions. It will also remove them from the object if they exist.
Top Interview Questions
?Interview Question
Q:What happens if you console.log an object directly?
A:
In a browser console, it shows an interactive dropdown. However, if used in an alert or document.write, it will often display the generic string '[object Object]'.
?Interview Question
Q:How do you convert an object to a list of its values?
A:
You can use the built-in Object.values(myObj) method, which returns an array of the object's property values.
?Interview Question
Q:Will JSON.stringify convert object methods?
A:
No. JSON.stringify() only converts data properties. Functions are omitted from the resulting JSON string.
Course4All Engineering Team
Verified ExpertSenior Full-Stack Engineers & V8 Experts
Our JavaScript and engine-level content is developed by a collective of senior engineers focused on high-performance web architecture and 2026 standards.
Pattern: 2026 Ready
Updated: Weekly
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.