When i write a function in JS or jQuery and a parameter is required, i use the if something.length
trick...
this.example = function(e) {
if ($(e).length) {
/*blablabla*/
} else {
return false;
}
}
But i dont want to do this in all functions. Is there a way to generalize this?
like:
this.ck = function(e) {
return function(e){
if (!(e.length)) { return false;}
}
}
this.example = function(e) {
ck(e)
/*blablabla*/
}