An Interest In:
Web News this Week
- March 27, 2024
- March 26, 2024
- March 25, 2024
- March 24, 2024
- March 23, 2024
- March 22, 2024
- March 21, 2024
October 10, 2021 10:45 am GMT
Original Link: https://dev.to/mhsohag11/answer-how-to-check-a-not-defined-variable-in-javascript-2bk2
Answer: How to check a not-defined variable in JavaScript
The only way to truly test if a variable is undefined
is to do the following. Remember, undefined is an object in JavaScript.
if (typeof someVar === 'undefined') { // Your variable is undefined}
Some of the other solutions in this thread will lead you to believe a variable
Original Link: https://dev.to/mhsohag11/answer-how-to-check-a-not-defined-variable-in-javascript-2bk2
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To