【发布时间】:2016-06-28 19:27:13
【问题描述】:
当名称与 JavaScript 中的参数名称相同时,如何从函数中访问全局变量?
var name = null;
function func(name) {
// How to set the global variable with the passed value
}
【问题讨论】:
-
在浏览器环境中,所有全局变量都存储在
window命名空间:window.name -
@MitchKarajohn 我假设“全局变量”实际上意味着全局变量:-)
标签: javascript variables scope global