Which of the following is a built-in method to convert an object to a JSON string?
A
JSON.stringify() B
JSON.parse() C
toJSON() D
objectToString()
Analysis & Theory
`JSON.stringify()` converts a JavaScript object to a JSON string.
What does `Object.keys(obj)` return?
A
Array of values B
Array of keys C
Object methods D
String of keys
Analysis & Theory
`Object.keys(obj)` returns an array of the object's own property names (keys).
What does `Object.values(obj)` return?
A
Array of keys B
Array of values C
Key-value pairs D
Number of properties
Analysis & Theory
`Object.values(obj)` returns an array of the object's own property values.
Which method returns an array of key-value pairs?
A
Object.combine(obj) B
Object.entries(obj) C
Object.pairs(obj) D
Object.map(obj)
Analysis & Theory
`Object.entries(obj)` returns an array of `[key, value]` pairs.
Which method checks if an object has a specific own property?
A
obj.hasKey() B
obj.exists() C
obj.hasOwnProperty() D
obj.contains()
Analysis & Theory
`hasOwnProperty()` checks if the object has the specified property directly.
What does `Object.assign()` do?
A
Deletes properties B
Creates an array C
Copies properties to another object D
Merges arrays
Analysis & Theory
`Object.assign()` copies properties from source objects to a target object.
What is the result of `typeof Object.create({})`?
A
'function' B
'object' C
'undefined' D
'array'
Analysis & Theory
`Object.create()` returns a new object — so the type is `'object'`.
Which method converts an object to a list of key-value arrays?
A
Object.list() B
Object.values() C
Object.keys() D
Object.entries()
Analysis & Theory
`Object.entries()` returns an array of `[key, value]` arrays.
Which method freezes an object so no changes can be made?
A
Object.preventChanges() B
Object.freeze() C
Object.lock() D
Object.seal()
Analysis & Theory
`Object.freeze()` prevents modification of existing properties or addition of new ones.
What does `Object.seal()` do?
A
Prevents changes to object properties and values B
Prevents adding or removing properties but allows changes to values C
Allows all changes D
Deletes all properties
Analysis & Theory
`Object.seal()` prevents adding or deleting properties, but allows modification of existing ones.