Common js system function usage instance analysis, js function instance analysis

Source: Internet
Author: User

Common js system function usage instance analysis, js function instance analysis

This example describes common system functions of JavaScript. Share it with you for your reference.

The Code is as follows:
Copy codeThe Code is as follows: <Head>
</Head>
<Body>
<Script type = "text/javascript">
// 1. The escape () function converts the string to the unicode encoding used by each computer platform. enescape () is used for decoding (turning back ().
Var str = 'wang mei ';
Document. write (escape (str ));
Document. write ("<br/> ");

// 2. Convert the string to an integer type or a floating point type. If the original string age does not start with a number, the result is NaN.
Var age = "26.9 hellow world ";
Document. write (parseInt (age); // parseInt () function
Document. write ("<br/> ");
Document. write (parseFloat (age); // parseFloat () function
Document. write ("<br/> ");

// 3. Determine whether a value or variable value is a non-number.
Var num = "30.9abc ";
If (isNaN (num )){
Document. write ("num is a non-digit ");
} Else {
Document. write ("num is a number ");
}
Document. write ("<br/> ");

// 4. Determine whether a value or variable value is poor.
Var result = 10/0;
If (isFinite (result )){
Document. write ("the result variable value is poor ");
} Else {
Document. write ("the value of the result variable is infinite ");
}

</Script>
</Body>
</Html>

I hope this article will help you design javascript programs.

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.