Back
If I have a JavaScript object, say
var myObject = new Object(); myObject["firstname"] = "Gareth"; myObject["lastname"] = "Simpson"; myObject["age"] = 21;
var myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
is there a built-in or accepted best practice way to get the length of this object?
The best way to get the length of this object is to use the below-mentioned way:-
Object.keys(myArray).length
Enroll in our web development online courses to become an Expert in Web Development!
31k questions
32.8k answers
501 comments
693 users