美文网首页
ES6 数组方法

ES6 数组方法

作者: AC编程 | 来源:发表于2023-11-22 11:26 被阅读0次

一、Math.min() 返回零个或更多个数值的最小值

Math.min.apply(Math, this.cars.map(item => item.attributes.price)) // 获取数组里price的最小值

二、find() 方法返回通过测试(函数内判断)的数组的第一个元素的值

this.cars.find(item => lowPrice === item.attributes.price) // 返回满足条件的item

三、findIndex()方法返回数组中满足提供的测试函数的第一个元素的索引。否则返回-1。

this.cars.findIndex(item => lowPrice === item.attributes.price)

相关文章

网友评论

      本文标题:ES6 数组方法

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