摘要:
一、相同点: 1.都是循环遍历数组中的每一项 2.每次执行匿名函数都支持三个参数,参数分别为item(当前每一项),index(索引值),arr(原数组) 3.匿名函数中的this都是指向window 4.只能遍历数组 二、不同点 1.map()会分配内存空间存储新数组并返回,forEach()不会 阅读全文
摘要:
出处:https://www.cnblogs.com/ygunoil/p/12107992.html 阅读全文
摘要:
1 var r, 2 ary = ['apple', 'strawberry', 'banana', 'pear', 'apple', 'orange', 'orange', 'strawberry']; 3 r = ary.filter(function (currentValue, index, 阅读全文