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

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

By Arvind Yadav in JavaScript on Mar 23 2022
  • suraj devgade
    Mar, 2022 27

    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.

    • 2
  • Rajeev Kumar
    Mar, 2023 9

    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.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS