lodash 数组元素查找 findIndex
生活随笔
收集整理的這篇文章主要介紹了
lodash 数组元素查找 findIndex
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
_.findIndex(array, [predicate=_.identity])
更多專業(yè)前端知識,請上 【猿2048】www.mk2048.com
這個(gè)方法類似?
_.find。除了它返回最先通過?predicate?判斷為真值的元素的 index ,而不是元素本身。 <!DOCTYPE html> <html lang="zh"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>數(shù)組元素查找</title></head><body><script src="https://cdn.bootcss.com/lodash.js/4.17.10/lodash.min.js"></script><script type="text/javascript">var users = [{'user': 'barney','active': false},{'user': 'fred','active': false},{'user': 'pebbles','active': true}];var index = _.findIndex(users, {'user': 'fred','active': false});console.log(index);//[3]</script></body></html>?
更多專業(yè)前端知識,請上 【猿2048】www.mk2048.com
總結(jié)
以上是生活随笔為你收集整理的lodash 数组元素查找 findIndex的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: lodash round
- 下一篇: es6 includes(), star