_.filter
Creates a new array with all elements that pass the test implemented by the provided function.
- // Underscore/Lodash
- function isBigEnough (value) {
- return value >= 10
- }
- var array = [12, 5, 8, 130, 44]
- var filtered = _.filter(array, isBigEnough)
- console.log(filtered)
- // output: [12, 130, 44]
- // Native
- function isBigEnough (value) {
- return value >= 10
- }
- var array = [12, 5, 8, 130, 44]
- var filtered = array.filter(isBigEnough)
- console.log(filtered)
- // output: [12, 130, 44]
Browser Support for Array.prototype.filter()
✔ | ✔ | 1.5 ✔ | 9 ✔ | ✔ | ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .