Is there a universal JavaScript function that checks that a variable has a value and ensures that it’s not undefined
or null
? I’ve got this code, but I’m not sure if it covers all cases:
function isEmpty(val){
return (val === undefined || val == null || val.length <= 0) ? true : false;
}