Dennis Thomas
When does JavaScript variable return undefined?
By Dennis Thomas in JQuery on Jan 29 2018
  • Dennis Thomas
    Jan, 2018 29

    A JavaScript variable returns undefined when it has not been assigned a value.For example:var a = "Test String"; // defined var b; // undefinedif (a === undefined) {var1 = "a is undefined"; } else {var1 = "a is defined"; }if (b === undefined) {var2 = "b is undefined"; } else {var2 = "b is defined"; }res = var1 + ", " + var2;The result of res will be:a is defined, b is undefined

    • 3
  • Kalyani Shevale
    Dec, 2018 27

    In JavaScript, undefined means a variable has been declared but has not yet been assigned a value, such as: var TestVar; alert(TestVar); //shows undefined alert(typeof TestVar); //shows undefined. null is an assignment value.

    • 1
  • Prem chandhar
    Jun, 2021 17

    if we didnt assign the value for the given input

    • 0
  • Bidyasagar Mishra
    Jul, 2019 12

    variable has declared but didnot assign yet

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS