2
Reply

What's the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states?

Arvind Yadav

Arvind Yadav

2y
2.9k
0
Reply

What’s the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states?

    Null is absence of memory for particular variable.
    e.g var a = null;
    undefined indicate value has not been assign to it.
    e.g var x; // x is undefined
    Undeclared means variable is not declared with any data type.

    null is a value of a variable and is a type of object. We use ‘console. log();’ and ‘type of’ to check if a variable is undefined or null. undeclared variables is a variable that has been declared without ‘var’ keyword.