学习记录-1
2016-06-30 20:52
323 查看
类型检测:typeof
typeof 100 typeof NaN //"number"
typeof true //"boolean"
typeof function //"function"
typeof(undefined) //"undefined"
typeof new Object() typeof [1,3] typeof null //"object"
instanceof //实例检测,检测到原型链上
[1,3] instanceof Array // true
[1,3] instanceof String // false
Object.prototype.toString
Object.prototype.toString.apply([]); // "[object Array]"
Object.prototype.toString.apply(function(){}); // "[object Funtion]"
Object.prototype.toString.apply(null); //"[object Null]"
Object.prototype.toString.apply(undefined); //"[object Undefined]"
PS: IE6/7/8的null会返回 "[object Object]"
数组方法:
arr.join(); //把数组的所有元素输出成字符串,并用指定分隔符连接,默认为“,”
arr.sort(); //排序
字符串方法:
str.split(","); //以特定字符分割字符串,同时返回成数组 这一点和 join()是反的
str.substring(start,end); //写法小写,作用提取字符串
str.indexOf("gdgdf"); //返回查询的子字符串起始位置,没有则返回-1
typeof 100 typeof NaN //"number"
typeof true //"boolean"
typeof function //"function"
typeof(undefined) //"undefined"
typeof new Object() typeof [1,3] typeof null //"object"
instanceof //实例检测,检测到原型链上
[1,3] instanceof Array // true
[1,3] instanceof String // false
Object.prototype.toString
Object.prototype.toString.apply([]); // "[object Array]"
Object.prototype.toString.apply(function(){}); // "[object Funtion]"
Object.prototype.toString.apply(null); //"[object Null]"
Object.prototype.toString.apply(undefined); //"[object Undefined]"
PS: IE6/7/8的null会返回 "[object Object]"
数组方法:
arr.join(); //把数组的所有元素输出成字符串,并用指定分隔符连接,默认为“,”
arr.sort(); //排序
字符串方法:
str.split(","); //以特定字符分割字符串,同时返回成数组 这一点和 join()是反的
str.substring(start,end); //写法小写,作用提取字符串
str.indexOf("gdgdf"); //返回查询的子字符串起始位置,没有则返回-1
相关文章推荐
- 进程间(Activity)通信
- shiro介绍
- ViewPagerIndication指针的使用
- vector subscript out of range
- css清除浮动float的三种方法总结
- Codeforces Round #360 (Div. 2) E. The Values You Can Make dp
- list组件应用
- Android 开源框架ViewPageIndicator的使用
- codeforces 687B Remainders Game【数学】
- Android 获取视频(本地和网络)缩略图的解决方案
- DIV布局之道四:clear:both清除DIV两侧浮动详解
- 链式前项星
- 怎样一开始打开activity就启动google的下拉刷新(仿优酷的下拉刷新)
- HDU-1036 Average is not Fast Enough!(模拟水题)
- 购物车练习
- [PHP]Yaf + composer 引起大幅性能下降
- RadioButton下划线效果的使用
- WCF、WebAPI、WebService之间的区别
- javaScript的null和undefined
- logstash-input-jdbc 同步原理及相关问题解读