JS判断字符串中是否包含数组的某一项

let arr = ['Hello','hi','John'];
let string1 = "Hello, what`s your name";
arr.every(str => string1.includes(str)) //-> true
|| 
let string1 = "Hi, what`s your name";
arr.some(str => string.includes(str)) //-> false

猜你喜欢

转载自blog.csdn.net/qq_43585322/article/details/129566270