JS函数
摘要:利用filter,可以巧妙地去除Array的重复元素: r = arr.filter(function (element, index, self) { return self.indexOf(element) index;}); 高阶函数reduce类似于递归,斐波那契: 总的来说,map的操作是
阅读全文
posted @
2017-02-24 10:16
大地主·赵
阅读(248)
推荐(0)
JS中的Map和Set
摘要:使用iterable内置的forEach方法 Set与Array类似,但Set没有索引,因此回调函数的前两个参数都是元素本身: Map的回调函数参数依次为value、key和map本身: a.forEach(function (element, index, array,adsf) { // ele
阅读全文
posted @
2017-02-23 16:19
大地主·赵
阅读(65642)
推荐(0)