Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 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)

The best way to get the length of this object is to use the below-mentioned way:-

Object.keys(myArray).length

Related questions

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

Browse Categories

...