我听说在js中,没有使用"var"初始化的变量将是全局变量。所以:
$(document).ready(function(){
function foo(){
//since i'm not using "var", will this function become global?
}
var bar = function(){
//is this the better way to declare the function?
}
})
如果它是全局的,为什么我无法在控制台中访问它。如果它不是全局的,并且其范围在函数中,省略 "var" 会影响性能吗?谢谢。
... = function foo() { }
很不错,加个赞。我之前不知道还能这样双重命名。 - Samantha Branham