JavaScript Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 2.20

Global Properties and Functions Defined in ECMAScript

This section provides a quick description of all global properties and functions mentioned in the ECMAScript specification.

There 3 built-in global properties with primitive values contained in the invisible "Global" object mentioned in the ECMAScript specification:

  • "NaN" - A global property that holds the special number value: NaN (Not A Number).
  • "Infinity" - A global property that holds the special number value: Infinity.
  • "undefined" - A global property that holds the undefined value: undefined.

There are 9 regular built-in global functions contained in the invisible "Global" object mentioned in the ECMAScript specification:

  • "eval(x)" - Evaluates the specified string a JavaScript expression and returns the result.
  • "parseInt(string, radix)" - Produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix.
  • "parseFloat(string)" - Produces a number value dictated by interpretation of the contents of the string argument as a decimal literal.
  • "isNaN(number)" - Returns true if the specified number is NaN.
  • "isFinite(number)" - Returns true if the specified number is a finite number.
  • "decodeURI(encodedURI)" - Decodes an encoded URI string back to a URI string.
  • "decodeURIComponent(encodedURIComponent))" - Decodes an encoded URI component string back to a URI component string.
  • "encodeURI(uri)" - Encodes a URI string by replacing replacing all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( ) # ; , / ? : @ & = + $, with escape sequences.
  • "encodeURIComponent(uriComponent)" - Encodes a URI component string by replacing all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( ), with escape sequences.

There are 9 special built-in global functions contained in the invisible "Global" object mentioned in the ECMAScript specification. These functions are really constructors of built-in object types:

  • "Object()" - Constructor of the Object object type.
  • "Function(...)" - Constructor of the Function object type.
  • "Array(...)" - Constructor of the Array object type.
  • "String(...)" - Constructor of the String object type.
  • "Boolean(...)" - Constructor of the Boolean object type.
  • "Number(...)" - Constructor of the Number object type.
  • "Date(...)" - Constructor of the Date object type.
  • "RegExp(...)" - Constructor of the RegExp object type.
  • "Error(...)" - Constructor of the Error object type.

There 1 built-in global properties with an object value contained in the invisible "Global" object mentioned in the ECMAScript specification:

  • "Math" - A global property that holds the default "Math" object which contains all mathematics related properties and functions.

In order to verify those global properties and functions, I wrote this simple script:

// Global_Object_Properties.html
// Copyright (c) 2008 by Dr. Herong Yang, http://www.herongyang.com/

   println("\nGlobal primitive-value properties:");
   println("   NaN: Type = "+(typeof this.NaN) 
      + ", Value = "+this.NaN);
   println("   Infinity: Type = "+(typeof this.Infinity) 
      + ", Value: "+this.Infinity);
   println("   undefined: Type = "+(typeof this.undefined) 
      + ", Value = "+this.undefined);

   println("\nGlobal functions:");
   println("   eval: Value = "+this.eval);
   println("   parseInt: Value = "+this.parseInt);
   println("   parseFloat: Value = "+this.parseFloat);
   println("   isNaN: Value = "+this.isNaN);
   println("   isFinite: Value = "+this.isFinite);
   println("   decodeURI: Value = "+this.decodeURI);
   println("   decodeURIComponent: Value = "+this.decodeURIComponent);
   println("   encodeURI: Value = "+this.encodeURI);
   println("   encodeURIComponent: Value = "+this.encodeURIComponent);

   println("\nGlobal constructors:");
   println("   Object: Value = "+this.Object);
   println("   Function: Value = "+this.Function);
   println("   Array: Value = "+this.Array);
   println("   String: Value = "+this.String);
   println("   Boolean: Value = "+this.Boolean);
   println("   Number: Value = "+this.Number);
   println("   Date: Value = "+this.Object);
   println("   RegExp: Value = "+this.RegExp);
   println("   Error: Value = "+this.Error);

   println("\nGlobal object-value property:");
   println("   Math: Type = "+(typeof this.Math) 
      + ", Value = "+this.Math);

If you run this script with "jrunscript", you will get:

Global primitive-value properties:
   NaN: Type = number, Value = NaN
   Infinity: Type = number, Value: Infinity
   undefined: Type = undefined, Value = undefined

Global functions:
   eval: Value = function eval() { [native code
   parseInt: Value = function parseInt() { [native code
   parseFloat: Value = function parseFloat() { [native code
   isNaN: Value = function isNaN() { [native code
   isFinite: Value = function isFinite() { [native code
   decodeURI: Value = function decodeURI() { [native code
   decodeURIComponent: Value = function decodeURIComponent() { [native
   encodeURI: Value = function encodeURI() { [native code
   encodeURIComponent: Value = function encodeURIComponent() { [native

Global constructors:
   Object: Value = function Object() { [native code
   Function: Value = function Function() { [native code
   Array: Value = function Array() { [native code
   String: Value = function String() { [native code
   Boolean: Value = function Boolean() { [native code
   Number: Value = function Number() { [native code
   Date: Value = function Object() { [native code
   RegExp: Value = function RegExp() { [native code
   Error: Value = function Error() { [native code

Global object-value property:
   Math: Type = object, Value = [object Math]

This confirms that the "jrunscript" does support all global properties and functions mentioned in the ECMAScript specification.

Table of Contents

 About This JavaScript Tutorial Example Book

 Introduction to JavaScript

 ECMAScript Language Specification and JavaScript Dialects

 Data Types, Variables and Expressions

 Flow Control Statements

 Creating, Accessing, and Manipulating Arrays

 Defining and Calling Functions

 Web Browser Supporting JavaScript

 Server-Side and Client-Side Web Scripting

 Introduction to Objects

 Defining Your Own Object Types

 Inheritance of Properties and Methods through the Prototype Object Chain

 'jrunscript' - JavaScript Shell Command from JDK

 Using Functions as "Function" Objects

Introduction to Built-in Object Types

 Overview of Built-in Object Types

 The "Object" Object Type - The Root Object Type

 The "Global" Object Type - The Invisible Global Container

Global Properties and Functions Defined in ECMAScript

 Global Properties and Functions Provided by "jrunscript"

 The "Function" Object Type - Functions Are Objects

 The "Array" Object Type - Arrays Are Objects

 The "String" Object Type - Not Equal to String Primitive Type

 The "Boolean" Object Type - Wrapping Boolean Values into Objects

 The "Number" Object Type - Not Equal to Number Primitive Type

 The "Date" Object Type - Managing Dates and Times

 The "RegExp" Object Type - Regular Expression Patterns

 The "Error" Object Type - Runtime Exceptions

 The "Math" Object Type - The Math Container

 W3C's Document Object Model (DOM) Specifications

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2008
Global Properties and Functions Defined in ECMAScript