Is there a javascript method to find substring in an array of strings?

前端 未结 5 1285
醉话见心
醉话见心 2021-01-26 08:58

Suppose my array is [\"abcdefg\", \"hijklmnop\"] and I am looking at if \"mnop\" is part of this array. How can I do this using a javascript method?

I tried this and it

5条回答
  •  我在风中等你
    2021-01-26 09:32

    var array= ["abcdefg", "hijklmnop"];
    var newArray = array.filter(function(val) {
        return val.indexOf("mnop") !== -1
    })
    console.log(newArray)
    

提交回复
热议问题