Any real difference between window.prompt and prompt?

前端 未结 1 1928
难免孤独
难免孤独 2021-01-23 11:08

Just out of curiosity is there any difference between window.prompt and prompt in JavaScript.

For one of the answers to my exam questions the teacher uses



        
1条回答
  •  猫巷女王i
    2021-01-23 11:52

    Usually yes, window.prompt === prompt. Yet it does depend on your scope, someone might have declared window or prompt variables with different values than those in the global scope.

    For further details have a look at Is window really global in Javascript?. You (and your teacher) also might be interested in Why is it beneficial to rely on the scope chain alone and avoid explicitly referencing the head object in Javascript?.

    0 讨论(0)
提交回复
热议问题