【发布时间】:2016-06-07 12:36:54
【问题描述】:
我正在学习 lodash。是否可以使用 lodash 在字符串数组中查找子字符串?
var myArray = [
'I like oranges and apples',
'I hate banana and grapes',
'I find mango ok',
'another array item about fruit'
]
是否可以确认“橙子”一词是否在我的数组中? 我试过 _.includes, _.some, _.indexOf 但他们都失败了,因为他们查看的是完整的字符串,而不是子字符串
【问题讨论】:
-
你能把数组加入一个字符串并使用indexOf吗?
标签: javascript arrays include lodash