JavaScript Global Objects

Source: Internet
Author: User

JavaScript Global Objects

Global properties and functions are available for all built-in JavaScript objects.

Top-level functions (global functions)
function Description
decodeURI () Decodes the URI of an encoding.
decodeURIComponent () Decodes a coded URI component.
encodeURI () Encodes a string as a URI.
encodeURIComponent () Encodes a string as a URI component.
Escape () Encodes a string.
Eval () Computes the JavaScript string and executes it as script code.
GetClass () Returns the Javaclass of a javaobject.
Isfinite () Checks if a value is a number that has a poor size.
IsNaN () Checks whether a value is a number.
Number () Converts the value of an object to a number.
Parsefloat () Parses a string and returns a floating-point number.
parseint () Parses a string and returns an integer.
String () Converts the value of an object to a string.
Unescape () Decodes a string encoded by escape ().
Top-level properties (global properties)
Method Description
Infinity Represents the numeric value of the positive infinity.
Java Represents a javapackage at the Java.* package level.
NaN Indicates whether a value is a numeric value.
Packages The root Javapackage object.
Undefined Indicates a value that is not defined.
Global Object Description

The global object is a predefined object, as a placeholder for JavaScript global functions and global properties. By using global objects, you can access all of the other predefined objects, functions, and properties. The global object is not a property of any object, so it does not have a name.

In the top-level JavaScript code, you can refer to the global object with the keyword this. However, it is not usually necessary to refer to the global object in this way because the global object is the header of the scope chain, which means that all unqualified variables and function names are queried as properties of the object. For example, when the JavaScript code references the parseint () function, it refers to the parseint property of the global object. A global object is the head of a scope chain and also means that all variables declared in the top-level JavaScript code will be properties of the global object.

A global object is just an object, not a class. There is neither a constructor function nor a new global object to instantiate.

When JavaScript code is embedded in a special environment, global objects typically have environment-specific properties. In fact, the ECMAScript standard does not specify the type of global objects, JavaScript implementations or embedded JavaScript can use any type of object as a global object, as long as the object defines the basic properties and functions listed here. For example, in JavaScript implementations that allow scripting Java through LiveConnect or related techniques, global objects are given the Java and package attributes listed here, and the GetClass () method. In client-side JavaScript, the global object is the Window object, which represents the Web browser windows that allow JavaScript code.

Example

In the JavaScript core language, the predefined properties of global objects are non-enumerable, and all global variables that are implicitly or explicitly declared can be listed in For/in Loop, as follows:

var variables = ""; for (var name in this) {variables + = name + "<br/>";} document.write (variables);

JavaScript Global Objects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.