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
var myNewValue = myObject && myObject.child && myObject.child.myValue;
This will never throw an error. If myObject, child, or myValue is null then myNewValue will be null. No errors will be thrown