![]() |
VOOZH | about |
The Object.getOwnPropertyNames() method in JavaScript is a standard built-in object which returns all properties that are present in a given object except for those symbol-based non-enumerable properties.
Object.getOwnPropertyNames(obj)This method accepts a single parameter as mentioned above and described below:
Example 1: In this example, we will check if an object contains some properties or not using the Object.getOwnPropertyNames() method in JavaScript.
Output:
Array ["val1", "val2", "val3", "val4"]
Array ["val1", "val2", "val3"]
"val1 : Geek1"
"val2 : Geek2"
"val3 : Geek3"
Example 2: In this example, we will check if an object contains some properties or not using the Object.getOwnPropertyNames() method in JavaScript.
Output:
Array ["prop", "method"]
Array ["foo", "getFoo"]
We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.
The browsers supported by Object.getOwnPropertyNames() method are listed below: