Common functions of javascript

Source: Internet
Author: User

Common functions of javascript

(1)AlertFunction: displays a warning dialog box, including an OK button.

(2)ConfirmFunction: A confirmation dialog box is displayed, including the OK and Cancel buttons.

(3)EscapeFunction: converts a character to a Unicode code.

(4)EvalFunction: calculates the result of an expression.

    eval("x=10;y=20;document.write(x*y)");    document.write(eval("2+2"));    var x=10;    document.write(eval(x+17));
The eval function can execute strings as javascript code, but this method is very violent and will affect the efficiency of javascript code. It is best to avoid using


(5)IsNaNFunction: test whether (true) No (false) is not a number.

(6)ParseFloatFunction: converts a string to a numeric value.

(7)ParseIntFunction: converts a string to an integer (number of digits can be specified ).

(8)PromptFunction: displays an input dialog box, prompting you to wait for user input. For example:

<Scriptlanguage = "javascript"> alert ("input error"); prompt ("enter your name", "name"); // (title, default value) confirm ("OK no! "); </Script>

(9)UnescapeFunction: decodes characters encoded by the escape function.

(10)IsFinite(Number) checks whether a value can be a finite number and returns True or False

(11)IsNaN(String) checks whether a value is not a finite number.

(12)DecodeURI() Is the encoded URI address decoding

(13)DecodeURIComponent() Is decoded by the encoded URI component.

(14)EncodeURI() Encrypt the string as URI

(15)EncodeURIComponent() Encode the string as a URI component

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.