JavaScript Object keys() function | Get keys of object

  • by

JavaScript Object keys() method returns an array of a given object’s own enumerable property names. The ordering of the properties is the same as that given by the object manually in a loop applied to the properties.


JavaScript object keys

A simple example code gets all keys of a given object.

<!DOCTYPE html>


    var obj = {name: "Martin", age: 30, city: "United States"};
    let res = Object.keys(obj);





JavaScript Object keys() function get keys of object

Do comment if you have any doubts or suggestions on this Js Object key topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.