javascript

Get all keys from an object using Javascript

You can use Object.keys() method to get all keys from an object. It will return the array of key names.

var obj = {
    "name": "Ankit",
    "username": "ankit01",
    "status": "active",
    "contact": "mail"
};

var all_keys = Object.keys(obj);
Output
["name","username","status","contact"]

Live Demo

Was this helpful?