JavaScript - 知识点总结
2015-09-11 17:36
573 查看
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;
--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;
相关文章推荐
- jsp导出excel浏览器兼容
- js cheatsheet
- 什么是jsp?什么是servlet?
- js
- JS 只能输入数字和两位小数的JS
- JavaScript HTML DOM 事件
- X-stream完美转换XML、JSON
- js re cheatsheet
- JavaScript HTML DOM - 改变CSS
- js糟粕
- Javascript 中 String.replace( ) 多种用法
- JavaScript日期格式化函数
- javascript html DOM 改变html
- JS实现动画原理一(闭包方式)
- extjs
- javascript html DOM
- javascript的继承种类
- JS-JQ实现TAB选项卡
- javascript中this的解析
- JS-JQ实现页面滚动时元素智能定位(顶部-其他部位)