window.prompt和prompt之间有什么真正的区别? [英] Any real difference between window.prompt and prompt?

查看:456
本文介绍了window.prompt和prompt之间有什么真正的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于好奇,window.prompt和JavaScript中的提示之间有任何区别。

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

var yourName = window.prompt("Please enter your first name here\n");

我用过

var yourName = prompt("Please enter your first name here\n");

这是一个书面考试,所以我觉得它没有多大区别。

It is a written exam so i felt it wouldn't make much difference.

推荐答案

通常是, window.prompt ===提示。但它确实取决于你的范围,有人可能已声明 window 提示变量的值与全局值不同范围。

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.

有关详细信息,请查看 Javascript窗口是否真正全局?。您(以及您的老师)也可能对为什么单独依赖范围链并避免显式引用头对象感兴趣Javascript?

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?.

这篇关于window.prompt和prompt之间有什么真正的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆