Confused about hoisting

前端 未结 5 1495
感情败类
感情败类 2021-01-21 03:09

consider these slightly two different versions of hoisting...

mylocation = \"dublin\" 
function outputPosition() {
    alert(mylocation);
    mylocation = \"fing         


        
5条回答
  •  醉酒成梦
    2021-01-21 03:40

    The output of first snippet must be "dublin" and "fingal" provided that mylocation is defined,otherwise its a reference error.

    For more details :

    http://bustingseams.blogspot.in/2009/08/another-javascript-pitfall-hoisting.html

提交回复
热议问题