JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

3.5 The Global Object

The sections above have explained JavaScript’s primitive types and values. Object
types—objects, arrays, and functions—are covered in chapters of their own later in this
book. But there is one very important object value that we must cover now. The global
object is a regular JavaScript object that serves a very important purpose: the properties
of this object are the globally defined symbols that are available to a JavaScript program.
When the JavaScript interpreter starts (or whenever a web browser loads a new page),
it creates a new global object and gives it an initial set of properties that define:
• global properties like undefined, Infinity, and NaN
• global functions like isNaN(), parseInt() (§3.8.2), and eval() (§4.12).
• constructor functions like  Date(),  RegExp(),  String(),  Object(), and  Array()
• global objects like Math and JSON (§6.9)
The initial properties of the global object are not reserved words, but they deserve to
be treated as if they are. §2.4.1 lists each of these properties. This chapter has already
described some of these global properties. Most of the others will be covered elsewhere
in this book. And you can look them all up by name in the core JavaScript reference
section, or look up the global object itself under the name “Global”. For client-side
JavaScript, the Window object defines other globals that you can look up in the client-
side reference section.
In top-level code—JavaScript code that is not part of a function—you can use the
JavaScript keyword this to refer to the global object:
var global = this;  // Define a global variable to refer to the global object
In client-side JavaScript, the Window object serves as the global object for all JavaScript
code contained in the browser window it represents. This global Window object has a
self-referential window property that can be used instead of this to refer to the global
object. The Window object defines the core global properties, but it also defines quite
a few other globals that are specific to web browsers and client-side JavaScript.
友情链接It题库(| 版权归yishouce.com所有| 友链等可联系|粤ICP备16001685号-1