The built-in functions on javascript

(1) parseInt () function

  Syntax: parseInt (string, [n])

    This function is mainly the first string of digital to digital conversion, if the string does not start number, the return NaN3;

  n is used to indicate the data string is a few decimal number, it is not necessary.

  For example: var str = "123abc"

  The output is 123

 

(2) parseFloat () function

  Syntax: parseFloat (string)

  This function is mainly the first string into a digital floating-point number, if the string does not start number, the return NaN3;

  For example: var str = "12.12abc"

  The output is 12.12

 

(3) isNaN () function

  Syntax: isNaN (num)

  The main function test whether a value is NaN, Description: num is NaN, the return true, true otherwise

  For example: var str1 = "12"

       var str2="12abc"

    The first returns false

    The second returns true 

(4) isFinite () function

  Syntax: isFinite (num)

  This function is mainly used to verify whether the parameters which is limited, Note: If num is a limited number of (or may be converted to the limited number), returns true, false otherwise

  

Guess you like

Origin www.cnblogs.com/aycn/p/12212725.html