JavaScript hex conversion

A, JavaScript hex conversion

toString () method to convert a Number object as a string, and returns the result.

Syntax: NumberObject.toString (radix)

When the parameter is 2, it NumberObject be converted to a string of binary valued

Parameter is 16, NumberObject is converted to a hexadecimal representation of the string value

(A) decimal to binary

the var 'aa = + 4 ; 
the console.log (aatoString ( 2 ))
 the var 'aa = 255 ; 
the console.log (aatoString ( 2))

(Two) decimal to hexadecimal

the var 'aa = 255 
the console.log (aatoString ( 16))

 

 

Two, Unicode code conversion

the fromCharCode () accepts a specified Unicode value, and then returns a string

Syntax: String.fromCharCode ( N1n2 , ...,  nX

n1, n2, ..., nX represents Unicode encoding one or more characters

Return value: String Returns the character encoding of Unicode characters represent

(A) coded decimal output character Unicode

 

 (B) the hexadecimal Unicode character encoding output

Note: ox hexadecimal

 

Guess you like

Origin www.cnblogs.com/nyw1983/p/11560109.html