SINGLETON BUILT-IN OBJECTS
ECMA-262 defines a built-in object as "any object supplied by an ECMAScript implementation, independent of the host environment, which is present at the start of the execution of an ECMAScript program." This means the developer does not need to explicitly instantiate a built-in object; it is already instantiated. You have already learned about most of the built-in objects, such as Object
, Array
, and String
. There are two singleton built-in objects defined by ECMA-262: Global
and Math
.
The Global Object
The Global
object is the most unique in ECMAScript because it isn't explicitly accessible. ECMA-262 specifies the Global
object as a sort of catchall for properties and methods that don't otherwise have an owning object. In truth, there is no such thing as a global variable or global function; all variables and functions defined globally become properties of the Global
object. Functions covered earlier in this book, such as isNaN()
, isFinite...