![]() |
VOOZH | about |
JaScript Reflect.ownKeys() method in Javascript is used to return an array of the target object's own property keys and it ignores the inherited properties.
Syntax:
Reflect.ownKeys( obj )
Parameters: This method accepts a single parameter as mentioned above and described below:
Return value: This method always returns the Array of the target object's own property keys.
Exceptions: A TypeError is an exception given as the result when the target is not an Object.
Below examples illustrate the Reflect.ownKeys() method in JavaScript:
Example 1: In this example, we will return the keys of the object using the Reflect.ownKeys() method in JavaScript.
Output:
[ 'property1', 'property2' ] [ 'length' ] [ 'ab', 'bc' ] [ 'ab', 'bc', 'ca' ] [ 'ab', 'bc', 'ca' ]
Example 2: In this example, we will return the keys of the object using the Reflect.ownKeys() method in JavaScript.
Output:
[ 'z', 'y', 'x' ] [ 'length' ] [ '34', '45', 'val', 'sdf', 'safss', 'val2', Symbol(comet), Symbol(meteor) ] [] [ 'hoo' ]
Supported Browsers: The browsers supported by JavaScript Reflect.ownKeys() method are listed below:
We have a complete list of Javascript Reflects methods, to check those go through the JavaScript Reflect Reference article.