The Reflect.ownKeys(object) method

The Reflect.ownKeys() method returns an array whose values represent the keys of the properties of a provided object. It ignores the inherited properties.

Here is the example code to demonstrate this method:

var obj = { a: 1, b: 2, __proto__: { c: 3 } }; var keys = Reflect.ownKeys(obj); console.log(keys.length); //Output "2" console.log(keys[0]); //Output "a" console.log(keys[1]); //Output "b"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.