DEV Community

loading...

Discussion on: How to Get an Object Length

Collapse
markokolombo profile image
Marko Kolombo • Edited

true story...

const object1 = {
  a: 'somestring',
  b: 42,
  c: false,
  [Symbol('ghost')]: '👻'
};

console.log(Object.values(object1).length); //>3
Thread Thread
krumpet profile image
Ran Lottem

I'm getting 3 for the length of both keys and values. The arrays are ["a", "b", "c"] and ["somestring", 42, false], respectively.