第39页 DATA TYPES
byhard (byhard.com)
- 章节名:DATA TYPES
- 页码:第39页
Number Conversions Number() //can be used on any data type; parseInt() //converting strings to numbers. parseFloat() //converting strings to numbers. var num1 = Number(“Hello world!”); //NaN var num2 = Number(“”); //0 var num3 = Number(“000011”); //11 var num4 = Number(true); //1 var num5 = Number("-011"); //-11 var num1 = parseInt(“1234blue”); //1234 var num2 = parseInt(“”); //NaN var num3 = parseInt(“0xA”); //10 - hexadecimal var num4 = parseInt(22.5); //22 var num5 = parseInt(“70”); //70 - decimal var num6 = parseInt(“0xf”); //15 - hexadecimal var num = parseInt(“0xAF”, 16); //175 var num1 = parseInt(”AF”, 16); //175 var num2 = parseInt(”AF”); //NaN var num111 = parseInt("70",9) // 63 var num1 = parseFloat(“1234blue”); //1234 - integer var num2 = parseFloat(“0xA”); //0 var num3 = parseFloat(“22.5”); //22.5 var num4 = parseFloat(“22.34.5”); //22.34 var num5 = parseFloat(“0908.5”); //908.5 var num6 = parseFloat(“3.125e7”); //31250000
byhard对本书的所有笔记 · · · · · ·
-
第31页 DATA TYPES
The typeof Operator Note that because typeof is an operator and not a function, no pare...
-
第35页 DATA TYPES
The Number Type 0开头表示八进制,如果解析不正确,会默认成10进制数。比如: var octalNum1...
-
第39页 DATA TYPES
-
第41页 DATA TYEPES
Character Literals var text="\u03a3"; alert(text.length) //1 Converting to a String var...
-
第46页 OPERATORS
Unary Operators ++,-- ➤ When used on a string that is a valid representation of a nu...
说明 · · · · · ·
表示其中内容是对原文的摘抄