Last active
December 11, 2015 08:09
-
-
Save MaraScott/4571535 to your computer and use it in GitHub Desktop.
Name : length(obj) - Language : JavaScript - type : function - platform : generic - description : count number of item in an object - tag : length, object
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
// isOneOf() : see https://gist.github.com/davask/4571536 | |
function length(obj) { | |
"use strict"; | |
var count = 0; | |
if (isOneOf(obj, 'Object')) { | |
for (var k in obj) { | |
if (obj.hasOwnProperty(k)) { | |
++count; | |
} | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment