List Keys on a Plain Object
Build a small object and print its keys.
var user = {
name: "Ada",
age: 36,
city: "London"
};
console.log(Object.keys(user));
console.log(Object.keys(user).length); How It Works
- Own string keys.
Object.keysreturns the three enumerable own names. - Array result. The return value is a normal array, so
.lengthworks. - Use for loops. You can map, filter, or loop over the key list like any other array.

