What's the difference between variable definition and declaration in JavaScript?

后端 未结 8 1402
情话喂你
情话喂你 2020-12-03 03:54

Is this a variable definition or declaration? And why?

var x;

..and is the memory reserved for x after this st

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 04:08

    In simple terms,

    undefined means value to the variable is not defined.

    not defined means the variable itself is not defined.

    var x; //value is not defined. So, x //undefined

    //y variable is not declared or defined. So, y // y is not defined

提交回复
热议问题