Last active
November 2, 2018 17:33
-
-
Save facelordgists/457684ec5c490433fd05b56367f943ad to your computer and use it in GitHub Desktop.
JS: How to check if a variable exists.js #javascript #js
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
if (typeof subProduct != "undefined") { | |
console.log('subProduct exists'); | |
} | |
// If doesn't exist | |
if (typeof subProduct == "undefined") { | |
console.log("subProduct doesn't exists"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment