lodash _.contains one of multiple values in string

前端 未结 3 2108
予麋鹿
予麋鹿 2021-02-13 02:17

Is there a way in lodash to check if a strings contains one of the values from an array?

For example:

var text = \'this is some sample text\';
var values         


        
3条回答
  •  野的像风
    2021-02-13 03:04

    Use _.some and _.includes:

    _.some(values, (el) => _.includes(text, el));
    

    DEMO

提交回复
热议问题