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,
undefined
null
The verbose method to check if value is undefined or null is:
return value === undefined || value === null;
You can also use the == operator but this expects one to know all the rules:
==
return value == null; // also returns true if value is undefined