Hoisting variables in JavaScript

后端 未结 5 1527
误落风尘
误落风尘 2020-12-06 20:50

I understand Hoisting of variables is done in Java Script. I am unable to get why it outputs as undefined

 do_something()
    {
    var foo = 2;    
    cons         


        
5条回答
  •  情歌与酒
    2020-12-06 21:55

    Only the declaration is hoisted. the assigned variables are not hoisted. So you are

提交回复
热议问题