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["
This method gets all your object's property names in an array, so you can get the length of that array which is equal to your object's keys' length.
Object.getOwnPropertyNames({"hi":"Hi","msg":"Message"}).length; // => 2