Last active
August 31, 2018 20:01
-
-
Save dtomasi/609809aaa0c2c003d26b to your computer and use it in GitHub Desktop.
get length on an Object
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
/** | |
* Global function for Counting length of an Object | |
* @copyright tomasiMEDIA 2013 | |
* @author Dominik Tomasi | |
* @date 09.10.13 | |
*/ | |
(function($,window){ | |
$.fn.objectLength = function(){ | |
var $this = $(this); | |
return count($this); | |
}; | |
window.objectLength = function(el){ | |
return count(el); | |
}; | |
function count(el){ | |
var count = 0; | |
var i; | |
for (i in el) { | |
if (el.hasOwnProperty(i)) { | |
count++; | |
} | |
} | |
return count; | |
} | |
})(jQuery,window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment