美文网首页
es6中map、forEach、filter、reduce比较

es6中map、forEach、filter、reduce比较

作者: Eastblue | 来源:发表于2018-01-12 19:41 被阅读0次

map forEach filter reduce都是针对数组。

map:遍历数组中每个元素并返回一个新数组,不改变原数组

forEach:遍历数组中每个元素但是没有返回值

filter:遍历数组中每个元素返回一个满足返回条件的新数组,起到一个过滤作用。

reduce:理解不是很清晰,谨慎使用。

建议参考:https://www.zhihu.com/question/24927450

相关文章

网友评论

      本文标题:es6中map、forEach、filter、reduce比较

      本文链接:https://www.haomeiwen.com/subject/igtqoxtx.html