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.