Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (47.6k points)

If I have a JavaScript object, say

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?

1 Answer

0 votes
by (106k points)
edited by

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! 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...