Object.keys()
Description
Object.keys()
returns an Array with the top-level property keys of a provided
Object. The Array does not contain keys for nested properties.
Object.keys()
does not change the original object.
Examples
Basic example
Object.keys({
bananas: 300,
limes: 200,
lemons: 500
})
[
"bananas",
"limes",
"lemons"
]
Nested Object properties
Object.keys()
only extracts an Object’s top-level property keys. It doesn’t
extract nested property keys.
Object.keys({
bananas: 300,
limes: 200,
lemons: {
organic: 500
}
})
// The results don't includes the nested `lemons.organic`
// property key.
[
"bananas",
"limes",
"lemons"
]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!