为了学习 JS OOP,我正在查看 jQuery 的源代码以更好地了解它们是如何做事的。我的问题可能看起来很简单,但我无法理解 jQuery 在其库顶部定义的几个变量背后的原因。代码如下所示。
(function( window, undefined ) {
// Use the correct document accordingly with window argument (sandbox)
var document = window.document,
navigator = window.navigator,
location = window.location;
....rest of code
What I don't understand is why they created variables for the document, navigator, and location objects. Does this resolve some type of browser bug? I don't understand the benefit of doing this.