Skip to content

Instantly share code, notes, and snippets.

Created April 18, 2015 16:09
function count(obj){
var i=0;
for(var prop in obj){i++;}
return i;
}
var a = { a: 1, b: 2 };
console.log(count(a));
var b = function(){};
console.log(count(b));
var c = [1, 2, 3];
console.log(count(c));
var d = [];
d[100] = 1;
console.log(count(d));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment