Check if variable has been declared
JS
S
JavaScriptf you are interested in knowing whether the variable hasn't been declared or has the value undefined, then use the typeof operator.
1
2if (typeof arg !== 'undefined') {
3 // is declared || values is not undefined
4}
5
6/* Falsy Values
7false
80
9""
10NaN
11null
12undefined
13*/Created on 3/6/2018