To iterate on Avi Flax answer Object.keys(obj).length is correct for an object that doesnt have functions tied to it
example:
obj = {"lol": "what", owo: "pfft"};
Object.keys(obj).length; // should be 2
versus
arr = [];
obj = {"lol": "what", owo: "pfft"};
obj.omg = function(){
_.each(obj, function(a){
arr.push(a);
});
};
Object.keys(obj).length; // should be 3 because it looks like this
/* obj === {"lol": "what", owo: "pfft", omg: function(){_.each(obj, function(a){arr.push(a);});}} */
steps to avoid this:
do not put functions in an object that you want to count the number of keys in
use a seperate object or make a new object specifically for functions (if you want to count how many functions there are in the file using Object.keys(obj).length
)
also yes i used the _ or underscore module from nodejs in my example
documentation can be found here http://underscorejs.org/ as well as its source on github and various other info
And finally a lodash implementation https://lodash.com/docs#size
_.size(obj)