Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




how to know number of elements in a javascript object

With below function we may get the number of elements in a javascript object

function countProperties(obj) {
var count = 0;

for(var prop in obj) {
if(obj.hasOwnProperty(prop))
++count;
}

return count;
}
Share this article   |    Print    |    Article read by 3329 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: No related interview question