Built-in objects
Definition: All objects provided by the ECMAScript implementation that are independent of the hosting environment appear when the ECMAScript program starts executing.
By definition, the developer does not have to explicitly instantiate the built-in object, it has been instantiated. Only two built-in objects are defined in ECMAScript-262, that is, global and math
Global
The global object is the most specific object in the ECMAScript because it does not actually exist at all.
Because there is no independent object in the ECMAScript, all functions must be methods of an object, such as the isNaN (), Isfinite (), parseint (), and parsefloat () mentioned earlier, are methods of the global object.
Escape (), encodeURI (), encodeURIComponent (), unescape (), decodeURI (), decodeURIComponent (), eval () are all global methods.
Escape () && encodeURI () && encodeuricomponent ()
These methods are used to encode strings.
Escape does not encode 69 characters: *,+,-,.,/,@,_,0-9,a-z,a-z
There are 82 encodeURI not encoded characters:!,#,$,&, ', (,), *,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,a-z
There are 71 encodeuricomponent characters that are not encoded:!, ', (,), *,-,.,_,~,0-9,a-z,a-z
Escape (): not recommended, obsolete
encodeURI (): Encoding The URL, example:
Copy Code code as follows:
encodeURI ("http://www.jb51.net/a file with spaces.html")
Outputs http://www.jb51.net/a%20file%20with%20spaces.html
encodeURIComponent (): Encode parameters, Examples:
Copy Code code as follows:
param1 = encodeURIComponent ("http://xyz.com/?a=12&b=55")
url = "http://domain.com/?param1=" + param1 + "¶m2=99";
Outputs http://www.domain.com/?param1=http%3A%2F%2Fxyz.com%2F%Ffa%3D12%26b%3D55¶m2=99
unescape () && decodeURI () && decodeuricomponent ()
These methods are used to decode strings.
eval ()
Eval () is probably the most powerful method in the ECMAScript language, which, like the entire JavaScript interpreter, takes a single parameter, the ECMAScript (or JavaScript) string to execute.
Example:
Copy Code code as follows:
var msg= "Hello World";
Eval ("Alert (msg)");//alert "Hello World"
Note that the Eval () feature is powerful, but also dangerous, and may be injected into the code, especially when you execute the content entered by the user with the eval.
all properties of the global object
Global is not only a method, it also has attributes, all properties of the global object:
Property |
Description |
Undefined |
literal amount of undifined type |
NaN |
Private value for non-number |
Infinity |
Private numeric value for infinity |
Object |
constructor of Object |
Array |
the constructor of the Array |
Function |
constructor for function |
Boolean |
Boolean Constructor |
String |
the constructor for String |
Number |
the constructor for number |
Date |
the constructor for Date |
Regexp |
Constructor for RegExp |
Error |
the constructor of the Error |
Evalerror |
Constructor for Evalerror |
Rangeerror |
Constructor for Rangeerror |
Referenceerror |
Constructor for Referenceerror |
SyntaxError |
Constructor for SyntaxError |
TypeError |
Constructor for TypeError |
Urierror |
Constructor for Urierror |
Author: Tian Xing Jian, self-improvement
Source: http://artwl.cnblogs.com