es5、6新添加的js方法
来源:互联网 发布:设计优化 设计变更 编辑:程序博客网 时间:2024/06/05 23:54
1、Object.keys(obj)
返回对象可被枚举的自身属性名数组
Object.keys({name:'star',age:23})
//['name','age']
2、Object.assign(target,obj,obj...)
把多个源对象自身可枚举属性拷贝给目标对象并返回目标对象
源对象属性会全部拷贝到目标对象,如有同属性会被覆盖
------------------------数组
1、every
//every 迭代数组值全部返回true才返回true
console.log(arr.every(function(val){
return val>0
}))
2、some
//some 迭代 只要有一个返回true就返回true
console.log(arr.some(function(val){
return val>0
}))
3、map
//map 循环数组函数内需要有return 返回新的值。
//map 最终会返回一个新数组,长度和操作数组一样
//可用于对数组值的计算并返回新数据
var b=arr.map(function(item,index){
console.log(item,index);
return item>0?item:''
})
console.log(b);
4、foreach
//foreach 是用来替换for的
//它循环数组,可以修改数组
arr.forEach(function(item,index){
arr[index]=item+10;
})
console.log(arr);
5、filter
//filter 循环数组,返回符合条件的新的数组
var newarr=arr.filter(function(item,index){
return item>12;
})
console.log(newarr,arr)
- es5、6新添加的js方法
- es5中js的数组 新增方法总结
- Atitit js版本es5 es6新特性
- js的规范写法ES5
- 给js对象添加新属性的方法
- JS 添加新节点的几种方法
- 了解一些es5的方法
- 模拟 ES5 的数组方法
- ES5-ES6的部分新特性
- [js] ES5
- Atitit js es5 es6新特性 attilax总结
- ES5中数组的常用方法
- ES5中新增的Array方法
- ES5之数组的map方法
- ES5中新增的Array方法
- ES5中Object的几种方法
- ES5新特性
- IE8对象不支持js方法keys() es5-shim
- Intent和PendingIntent的区别
- C#中可以用XmlDocument类操作Xml文件
- 封装函数获取样式
- 2016年cocos2d-x v3.10总体开发环境WIN7-64位安装步骤
- C#操作XML之——读取XML节点
- es5、6新添加的js方法
- js 清除最后一位 例如逗号
- 当CompositeSubscription遇到了FragmentManager
- find()函数
- 大钟的ios开发之旅(8)————如何优化UITableView
- dom4j解析xml
- 利用反射访问数组
- LeetCode - Minimum Depth of Binary Tree
- opengl es 2.0 读书笔记1-什么是OpenGL ES