JavaScript global Functions Use simple description _ Basics

Source: Internet
Author: User
Tags eval
1, decodeURI () parameter: string

Function Description: Decodes the URI encoded by the encodeURI () function.

Instance:

The http://www.jb51.net/My%20first/can be decoded to http://www.jb51.net/My first/

2, decodeURIComponent () parameter: string

Function Description: The function can decode the URI encoded by the encodeURIComponent () function.

3, encodeURI () parameter: string

Function Description: The string can be encoded as a URI.

Tip: If the URI component contains delimiters, for example? and #, you should encode each component separately using the encodeURIComponent () method.


4, encodeURIComponent ()

Function Description: The string can be encoded as a URI component.

Notice the difference between the encodeURIComponent () function and the encodeURI () function, which assumes that its arguments are part of the URI (such as protocol, host name, path, or query string).

Therefore, the encodeURIComponent () function escapes the punctuation marks used to separate parts of the URI.

5, Escape () parameter: string

Feature Description: Strings can be encoded so that the string can be read on all computers. This method does not encode ASCII letters and numbers,

The following ASCII punctuation marks are not encoded:-_. ! ~ * ' (). All other characters will be replaced by escape sequences.

Warm tip: ECMAScript v3 against using this method, the application uses decodeURI () and decodeuricomponent () to replace it.

6, unescape () parameter: string

Function Description: You can decode a string encoded by escape (). The function works like this: by finding a sequence of characters in the form%xx and%uxxxx (x represents a hexadecimal number),

The Unicode character \u00xx and \uxxxx are substituted for such sequences of characters for decoding.

Warm tip: ECMAScript v3 has removed the unescape () function from the standard and objected to its use, so it should be replaced with decodeURI () and decodeURIComponent ().

7. Eval () Parameter: string

Function Description: You can compute a string and execute the JavaScript code in it.

Instance:

document.write (eval ("12+2")) will output 14
Note: The parameter must be of type string, otherwise the method will return without any changes.
8, Isfinite () parameter: number
Function Description: Used to check whether its parameters are large or poor. If number is finite (or can be converted to a finite number),
Then return True. Otherwise, returns False if number is NaN (non-numeric), or positive or negative infinity.
Instance:
Isfinite (-125) and Isfinite (1.2) return True,
The Isfinite (' Easy water cold ') and isfinite (' 2011-3-11 ') return false.
9, isNaN () parameter: Unlimited
Function Description: A function is used to check whether its arguments are non-numeric values.
Instance:
isNaN (123) and isNaN (0) return False
isNaN ("Easy water cold") and isNaN ("100") return true.
Note: You can use the isNaN () function to detect arithmetic errors, such as dividing by 0.
10, Number () Parameters: Unlimited
Function Description: Converts the value of an object to a number. If the parameter is a Date object, number () returns milliseconds from January 1, 1970 to the present. If the value of an object cannot be converted to a number, then the numbers () function returns NaN. Instance:
var test1= new Boolean (true);
var test2= new Boolean (false);
var test3= new Date ();
var test4= new String ("999");
var test5= new String ("999 888");

document.write (number (test1)); Output 1
document.write (number (test2)); Output 0
document.write (number (TEST3)); Output 1256657776588
document.write (number (test4)); Output 999
document.write (number (TEST5)); Output NaN
And also
Parsefloat () parseint () String () add it later!
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.