Javascript Hoisting in Chrome And Firefox

前端 未结 3 545
悲哀的现实
悲哀的现实 2020-12-28 20:52

Running this in Chrome and Firefox gives different answers:

(function() {

        if(true) {
            function f() { alert(\"yes\"); };
        } else {
         


        
3条回答
  •  天命终不由人
    2020-12-28 21:29

    From V8 (Chrome JavaScript engine) bug tracker:

    Not a bug. Firefox is the only browser that does what you're expecting.

    The behavior of Safari and IE on this is the same as Chrome's/V8's.

提交回复
热议问题