Fourth day of the second quarter part2

Data type conversion

Into a string

String (value) transformation function

Can any type of value this function transformation into a string

  • If the values ​​are toString () method is to use this method (calling toString no parameters, the default decimal)
  • If the value is null and undefined undefined and null is returned

toString () method     ---- index.toString (parameter (this parameter is a number converted to a string of hexadecimal number))

In addition to null and undefined values ​​do not have this method, the value of other types have this method

Into digital

Number () function (default decimal )

  • It can be transformed into any type
  • String type:
  • If 0 is the empty string
  • Recognition - + number (other symbols returns NaN)
  • null Type: return 0
  • undefined type: returns undefined
  • Value Type: unchanged
  • boolean type: true: 1 false: 0
  • Complex and unreasonable

The following two special strings to digital conversion

parseInt (parameter 1, parameter 2 (preferably set to 10 decimal)) (value Type more care Meets) function

Ignore spaces in front of the string, only to find alphanumeric characters and the minus / plus

An empty string will return NaN

Encountered non-numeric characters will terminate

parseFloat () function can only be resolved resolved decimal decimal

 


 

Higher-order functions

Function can be passed as parameters


 

Guess you like

Origin www.cnblogs.com/-constructor/p/11697974.html