![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数组
文章平均质量分 70
唐月123456
这个作者很懒,什么都没留下…
展开
-
js 字符截取与分割
substring()substring(start,end)表示从start到end之间的字符串,包括start位置的字符但是不包括end位置的字符。substring 方法使用 start 和 end 两者中的较小值作为子字符串的起始点start 或 end 为 NaN 或者负数,那么将其替换为0子字符串的长度等于 start 和 end 之差的绝对值 let str = '测试substring' console.log(str.substring(0,2)) // 测试subst原创 2021-08-20 15:34:13 · 745 阅读 · 0 评论 -
js常用的数组遍历
filter()filter 遍历数组会返回一个新的数组不会对空数组进行检测、不会改变原数组 let arrUsed = [1,2,3,4,5] let arrNew = arrUsed.filter((item, index) =>{ return item > 3 }) console.log(arrNew, arrUsed) // [4, 5] [1, 2, 3, 4, 5]some()符合条件返回 true ,不符合返回 false依原创 2021-07-12 15:48:55 · 303 阅读 · 0 评论 -
js 数组转换操作
1、ES6语法find查找匹配数组let data = [ {id:1,value:false}, {id:2,value:false}, {id:3,value:false}];let id = 3let findVal = data.find(item => { return item.id === id})findVal.value = true; //修改匹配项的值2、ES6 findIndex 对象数组查找某一个对象findIndex(原创 2020-06-29 11:50:38 · 1610 阅读 · 0 评论