Created
April 18, 2015 16:09
-
-
Save anonymous/b2ffe3fc217f11dd2877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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