Recall & Review
beginner
What are object keys in JavaScript?
Object keys are the names or identifiers used to access values stored in an object. They are always strings or symbols.
Click to reveal answer
beginner
How do you get all keys of an object in JavaScript?
You use
Object.keys(yourObject) to get an array of all keys in the object.Click to reveal answer
beginner
What does
Object.values(obj) return?It returns an array containing all the values of the object's own enumerable properties.
Click to reveal answer
intermediate
Can object keys be numbers in JavaScript?
No, object keys are always strings or symbols. If you use a number, JavaScript converts it to a string.
Click to reveal answer
intermediate
How can you loop through all keys and values of an object?
You can use a
for...in loop to go through keys, then access values with obj[key]. Or use Object.entries(obj) to get key-value pairs.Click to reveal answer
Which method returns an array of an object's keys?
✗ Incorrect
Object.keys() returns an array of the object's own enumerable property names (keys).
What type are object keys in JavaScript?
✗ Incorrect
Object keys are always strings or symbols. Numbers are converted to strings.
What does Object.values(obj) return?
✗ Incorrect
Object.values(obj) returns an array of the object's own enumerable property values.
How can you get both keys and values together from an object?
✗ Incorrect
Object.entries() returns an array of [key, value] pairs from the object.
What happens if you use a number as an object key?
✗ Incorrect
JavaScript converts number keys to strings automatically.
Explain how to retrieve all keys and values from a JavaScript object.
Think about methods that return arrays representing keys, values, or both.
You got /4 concepts.
Describe what types object keys can be and what happens if you use a number as a key.
Consider how JavaScript treats keys internally.
You got /3 concepts.