Created
July 19, 2010 09:49
-
-
Save badsyntax/481216 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// usage: var size = $.size( selectorOrObject ); | |
// code borrowed from: http://stackoverflow.com/questions/5223/length-of-javascript-associative-array | |
$.size = function(obj){ | |
if ( typeof obj === 'object' ) { | |
var size = 0, key; | |
for (key in obj) { | |
if ( obj.hasOwnProperty( key ) ) { | |
size++; | |
} | |
} | |
return size; | |
} else { | |
return $( obj ).size(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment