---
id: javascript-object-display
title: "JavaScript Object Display"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["JS object display", "object Object", "JSON.stringify", "Object.values", "Object.entries", "for in loop", "display object"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.89
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["javascript", "js", "web", "frontend", "w3schools", "objects", "display", "json"]
raw_sources: ["https://www.w3schools.com/js/js_object_display.asp"]
applied_in: []
github_commit: ""
---
# [[JavaScript Object Display]]
## π― ν μ€ ν΅μ°° (One-line insight)
Displaying a JavaScript object directly outputs `[object Object]`; to show its data, name the properties, loop over them, or convert the object with `Object.values()`/`Object.entries()`/`JSON.stringify()`. [S1]
## π§ ν΅μ¬ κ°λ
(Core concepts)
- **Direct display gives `[object Object]`** β this appears when you insert an object where a string is expected. [S1]
- **Name the properties** β properties can be concatenated into a string by name. [S1]
- **Loop with `for...in`** β collect property values in a loop, using `person[x]` (not `person.x`). [S1]
- **`Object.values()`** β creates an array from the property values. [S1]
- **`Object.entries()`** β makes it simple to use objects in loops as `[key, value]` pairs. [S1]
- **`JSON.stringify()`** β converts an object to a JSON-notation string; built in and supported in all browsers. [S1]
## π§© μΆμΆλ ν¨ν΄ (Extracted patterns)
- **`for...in` with bracket access** β `text += person[x]` works because `x` is the loop variable holding the key. [S1]
- **Values-to-string** β `Object.values(person).toString()` flattens values into a comma-joined string. [S1]
- **Destructured entries loop** β `for (let [fruit, value] of Object.entries(fruits))` iterates key/value pairs. [S1]
## π μΈλΆ λ΄μ© (Details)
**How to Display JavaScript Objects?**
Displaying a JavaScript object will output `[object Object]`. [S1]
```javascript
// Create an Object
const person = {
name: "John",
age: 30,
city: "New York"
};
let text = person;
```
**Why do I See [object Object]?**
`[object Object]` appears when you attempt to insert an object (a data structure containing properties) into a context where a string is expected; it represents how JavaScript handles this situation. Solutions include displaying the object properties by name, in a loop, via `Object.values()`, or via `JSON.stringify()`. [S1]
**Displaying Object Properties**
The properties of an object can be added in a string: [S1]
```javascript
// Create an Object
const person = {
name: "John",
age: 30,
city: "New York"
};
// Add Properties
let text = person.name + "," + person.age + "," + person.city;
```
**Using a For .. In Loop**
The properties of an object can be collected in a loop: [S1]
```javascript
// Create an Object
const person = {
name: "John",
age: 30,
city: "New York"
};
// Build a Text
let text = "";
for (let x in person) {
text += person[x] + " ";
};
```
You must use `person[x]` in the loop. `person.x` will not work, because `x` is the loop variable. [S1]
**Using Object.values()**
`Object.values()` creates an array from the property values: [S1]
```javascript
// Create an Object
const person = {
name: "John",
age: 30,
city: "New York"
};
// Create an Array
const myArray = Object.values(person);
// Stringify the Array
let text = myArray.toString();
```
**Using Object.entries()**
`Object.entries()` makes it simple to use objects in loops: [S1]
```javascript
const fruits = {Bananas:300, Oranges:200, Apples:500};
let text = "";
for (let [fruit, value] of Object.entries(fruits)) {
text += fruit + ": " + value + "
";
}
```
**Using JSON.stringify()**
JavaScript objects can be converted to a string with the JSON method `JSON.stringify()`. `JSON.stringify()` is included in JavaScript and supported in all browsers. The result is a string written in JSON notation: [S1]
```javascript
{"name":"John","age":50,"city":"New York"}
```
```javascript
// Create an Object
const person = {
name: "John",
age: 30,
city: "New York"
};
// Stringify Object
let text = JSON.stringify(person);
```
## βοΈ λΉκ΅ λ° μ ν κΈ°μ€ (Comparison & decision criteria)
| Technique | Output shape | Use when |
| --- | --- | --- |
| Property by name | Hand-built string | You know the exact properties [S1] |
| `for...in` loop | Concatenated values | Iterate all properties generically [S1] |
| `Object.values()` | Array of values | You only need the values [S1] |
| `Object.entries()` | `[key, value]` pairs | You need both keys and values in a loop [S1] |
| `JSON.stringify()` | JSON-notation string | Serialize the whole object [S1] |
## π οΈ μ μ© μ¬λ‘ (Applied in summary)
The page's own snippets are the canonical applied examples β the `[object Object]` pitfall, property-by-name concatenation, the `for...in` loop, `Object.values().toString()`, the `Object.entries()` destructured loop, and `JSON.stringify(person)`. No external project/commit applications found in the source.
## π» μ½λ ν¨ν΄ (Code patterns)
For...in loop (note bracket access):
```javascript
let text = "";
for (let x in person) {
text += person[x] + " ";
};
```
Entries loop with destructuring:
```javascript
for (let [fruit, value] of Object.entries(fruits)) {
text += fruit + ": " + value + "
";
}
```
Serialize to JSON:
```javascript
let text = JSON.stringify(person);
```
## βοΈ λͺ¨μ λ° μ
λ°μ΄νΈ (Contradictions & updates)
No contradictions found in the source.
## β
κ²μ¦ μν λ° μ λ’°λ
- **μν:** draft
- **κ²μ¦ λ¨κ³:** conceptual (μ€μ μ μ© μ¬λ‘ λ°κ²¬ μ applied/validatedλ‘ μΉκ²© κ°λ₯)
- **μΆμ² μ λ’°λ:** B (W3Schools β widely used educational reference, not a primary standards body)
- **μ λ’° μ μ:** 0.89
- **μ€λ³΅ κ²μ¬ κ²°κ³Ό:** μ κ· μμ± (New discovery)
## π μ§μ κ·Έλν (Knowledge Graph)
- **μμ/루νΈ:** [[JavaScript Tutorial]]
- **κ΄λ ¨ κ°λ
:** [[JavaScript Objects]], [[JavaScript Object Properties]], [[JavaScript Object Methods]]
- **μ°Έμ‘° λ§₯λ½:** Referenced whenever rendering object data to the page or serializing it for transport.
## π μΆμ² (Sources)
- [S1] W3Schools β JavaScript Object Display β https://www.w3schools.com/js/js_object_display.asp
## π λ³κ²½ μ΄λ ₯ (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Object Display" page (Astra wiki-curation, P-Reinforce v3.1 format).