_.includes
Checks if a value is in collection.
- var array = [1, 2, 3]
- // Underscore/Lodash - also called _.contains
- _.includes(array, 1)
- // output: true
- // Native
- var array = [1, 2, 3]
- array.includes(1)
- // output: true
- // Native (does not use same value zero)
- var array = [1, 2, 3]
- array.indexOf(1) > -1
- // output: true
Browser Support for Array.prototype.includes
47.0 ✔ | 14.0 ✔ | 43.0 ✔ | ✖ | 34.0 ✔ | 9.0 ✔ |
Browser Support for Array.prototype.indexOf
✔ | ✔ | 1.5 ✔ | 9.0 ✔ | ✔ | ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .