I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?
const myObject = new Object(); myObject["
If you need an associative data structure that exposes its size, better use a map instead of an object.
const myMap = new Map(); myMap.set("firstname", "Gareth"); myMap.set("lastname", "Simpson"); myMap.set("age", 21); console.log(myMap.size); // 3