
es6
es6
卍 夏至
4年工作经验,熟悉web、小程序、移动端开发
展开
-
js数组查找方法总结
1,indexOf() let arr = [1, 2, 3, 4, 5, 6]; arr.indexOf(7) //-1 arr.indexOf(6) //5 要检索的字符串值出现返回下标,没有出现返回 -1 2,includes() let arr = [1, 2, 3, 4, 5, 6]; arr.includes(7) //false arr.includes(6) //true 是否包含一个指定的值,如果是返回 true,否则false 3,filter() let arr = [1,原创 2020-05-13 17:39:59 · 2844 阅读 · 0 评论 -
es6数组新增方法总结
Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组。 Array.from(arrayLike[, mapFunction[, thisArg]]) arrayLike:必传参数,想要转换成数组的伪数组对象或可迭代对象。 mapFunction:可选参数,mapFunction(item,index){…} 是在集合中的每个项目上调用的函数。返回的值将插入到新集合中。 thisArg:可选参数,执行回调函数 mapFunction 时 this 对象。这个参数很少使用 1,类原创 2020-05-09 16:42:23 · 279 阅读 · 0 评论 -
es5、es6数组遍历方法
ES5: 1、for let items=[1,2,3,4,5] for(let i=0;i<items.length;i++){ console.log(items[i]) //1 2 3 4 5 } 2、forEach items.forEach(function(item){ //不支持break、continue console.log(item) //1...原创 2020-04-27 13:57:12 · 328 阅读 · 0 评论