摘要: 一、相同点: 1.都是循环遍历数组中的每一项 2.每次执行匿名函数都支持三个参数,参数分别为item(当前每一项),index(索引值),arr(原数组) 3.匿名函数中的this都是指向window 4.只能遍历数组 二、不同点 1.map()会分配内存空间存储新数组并返回,forEach()不会 阅读全文
posted @ 2020-03-13 15:02 敲代码的羔羊 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 出处:https://www.cnblogs.com/ygunoil/p/12107992.html 阅读全文
posted @ 2020-03-13 14:53 敲代码的羔羊 阅读(2564) 评论(0) 推荐(0) 编辑
摘要: 1 var r, 2 ary = ['apple', 'strawberry', 'banana', 'pear', 'apple', 'orange', 'orange', 'strawberry']; 3 r = ary.filter(function (currentValue, index, 阅读全文
posted @ 2020-03-13 14:43 敲代码的羔羊 阅读(261) 评论(0) 推荐(0) 编辑