A generic method to check the length of any type of variable. It will return a numeric representation of any JS type.
The function wll return a length for any variable that has a distinguishable length (Array,Object,String,Number). It will also return a length for these types:
This reasoning behind this is to allow the method to distinguish between empty and non-empty variables.
$count('abc'); //3 $count({'a':'b','c':'d'}); //2 $count([1,2,3]); //3 $count(2); //2 $count(function(){}); //0 $count(function(){return 'a';});//1
A more useful (though very generic) use-case:
if ($count(obs)){ //use the variable }else{ return; }
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus