【发布时间】:2020-07-30 05:48:07
【问题描述】:
我想在一个数组中查找多个值。搜索时,我希望能够使用 SQL 中的 LIKE 语句之类的东西。
arr = ['end', 'start_date', 'hello', 'end_dt', 'pub_date']
当我这样做时:
let el = arr.find(a => a.includes('date') || a.includes('dt'));
现在它只返回它找到的第一个值,start_date
我需要它返回:
start_date
end_dt
pub_date
我该怎么做?
【问题讨论】:
-
使用
filter而不是find
标签: javascript jquery arrays ecmascript-6 include