带有'undefined'参数的JavaScript函数 [英] JavaScript function with 'undefined' parameter
本文介绍了带有'undefined'参数的JavaScript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
绕过Modernizr源代码我发现了一件奇怪的事情:
Going around Modernizr source code I have found strange thing:
window.Modernizr = (function(window,document,undefined) {
之后,将使用两个参数调用此函数( this, this.document
)。
After that this function will be called with two arguments (this, this.document
).
为什么 undefined
在这里使用?有意义还是它只是奇怪的代码风格?
Why undefined
is used here? Is it meaningful or it's just strange code-style?
推荐答案
创建一个本地未定义
有人在范围链中的某处重新定义 undefined
。
Creates a local undefined
in case someone redefines undefined
somewhere in the scope chain.
自以来提供更快的查找速度undefined
是一个全局属性,因此范围链遍历减少了。
Also provides a faster lookup since undefined
is a global property, so the scope chain traversal is reduced.
这篇关于带有'undefined'参数的JavaScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文