Predict Object.keys Output
Predict Output Easy
Question
What does this code print?
Code
const user = { name: "Ada", age: 36, role: "admin" };
console.log(Object.keys(user));
Hint
Object.keys returns an array of the object's own enumerable property names.
Explanation
Object.keys(user) returns an array of the object's own enumerable property names (keys). For { name: 'Ada', age: 36, role: 'admin' }, the keys are ['name', 'age', 'role']. The order follows insertion order for string keys.
Related Resources
Related Lessons
- JavaScript Objects
Learn about Object.keys.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.