You can simply use the Object. keys() method along with the length property to get the length of a JavaScript object . The Object. keys() method returns an array of a given object’s own enumerable property names, and the length property returns the number of elements in that array.