1. js中变量为若类型,typeof 可以确定一个变量的数据类型
--undefined 值未定义
--boolean 布尔
--string 字符串
--number 数值
--object 对象或者null
--function 函数
eg: var b = (typeof 19.0 == "number"); typeof b; //boolean and b = true;
2. toString() 方法
--无论数字是什么类型,toString()默认都是按照十进制来输出
--基模式:带一个进制参数
eg: document.write((8).toString(2)); //1000
3. parseInt() 方法:第一个参数是要解析的字符串,第二个可选,默认十进制
eg: parseInt("1000", 2); //8
4. +运算符
2 + 3; //5
"2" + "3" ; //23
"2" + 3; //23
1 + 2 + "3"; //33
5. NaN
var nan = NaN;
nan === NaN ; //false
isNaN(nan); //true
6. 字符串String
var s = new String("hello);
s = s + "world"; //hello world;
s[4]; //o;
typeof s; //object
typeof "hello"; //string
var s1 = new String("hello");
var s2 = new String("hello");
s1 === s2; //false;
s1 == s2; //false;