Xpode.com        Click here to Print this article.

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;
}


http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=596

Click here to go on website