This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I generally use the typeof operator: | |
if (typeof obj.foo !== 'undefined') { | |
// your code here | |
} | |
// It will return "undefined" either if the property doesn't exist or its value is undefined. | |
// There are other ways to figure out if a property exists on an object, like the hasOwnProperty method: |