美文网首页
map(),filter()的使用

map(),filter()的使用

作者: Wanlly | 来源:发表于2021-12-13 11:54 被阅读0次

map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。
map() 不会对空数组进行检测。
map() 不会改变原始数组。

this.selectedRowKeys = this.feeList.map((element) => {
if (element.payState * 1 === 0) {
return element.feeId
}
})

filter() 方法创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素,也就是过滤数组。
注意: map() 不会对空数组进行检测。
注意: map() 不会改变原始数组。

this.selectedRowKeys = this.selectedRowKeys.filter((item) => {
return item
})

相关文章

网友评论

      本文标题:map(),filter()的使用

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