DEV Community

loading...

Discussion on: How to Get an Object Length

Collapse
samanthaming profile image
Samantha Ming Author

If you only want the enumerable properties without the symbols. The Object.keys method should just work, since it doesn't include that. If I misunderstood your questions, please follow up 🙂

Collapse
nickymeuleman profile image
Nicky Meuleman • Edited

All enumerable properties, including ones with Symbols as keys.
Excluding all non-enumerable properties.

an object with:
1 enumerable property with string as key,
2 non-enumerable properties with a string as key,
1 enumerable property with Symbol as key
1 non-enumerable properties with Symbol as key.

Should return 2 as total length. (1 for string key and 1 for Symbol key)