TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript Reflect ownKeys() Method

JavaScript Reflect ownKeys() Method with examples on javascript reflect methods, apply() construct(), defineProperty() method, deleteProperty(), get(), getOwnPropertyDescriptor(), getPrototypeOf(), has(), isExtensible(), ownKeys(), setPrototypeOf() etc.

<< Back to JAVASCRIPT

JavaScript Reflect.ownKeys() Method

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

Syntax:

Reflect.ownKeys(obj)

Parameters:

Obj: It is the target object from which to get the own keys.

Return value:

IT returns an Array of the target object's own property keys.

Exceptions:

A TypeError, if the target is not an Object.

Browser Support:

Chrome 49
Edge 12
Firefox 42
Opera 36

Example 1

const obj = {a: 5, b: 5};
console.log(Reflect.ownKeys(obj));
console.log(Object.keys(obj));

Output:

 ["a", "b"]
["a", "b"]

Example 2

const obj = {a: 5, b: 5};
const obj1 = {a: 5, b: 5, c:7};

console.log(Reflect.ownKeys(obj));	
console.log(Object.keys(obj1));
console.log(Reflect.ownKeys(obj1));

Output:

 ["a", "b"]
 ["a", "b", "c"]
 ["a", "b", "c"]

Example 3

var obj1 = Object.create({}, { hoo: { value: function() { return this.hoo; } } });
console.log(Object.keys(obj1)); 
console.log(Reflect.ownKeys(obj1)); 

Output:

  []
 ["hoo"]
Next TopicJavaScript Reflect




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf