How to search for a string inside an array of strings

前端 未结 4 1483
梦如初夏
梦如初夏 2020-11-27 04:06

After searching for an answer in other posts, I felt I have to ask this. I looked at How do I check if an array includes an object in JavaScript? and Best way to find if an

4条回答
  •  有刺的猬
    2020-11-27 05:10

    It's as simple as iterating the array and looking for the regexp

    function searchStringInArray (str, strArray) {
        for (var j=0; j

    Edit - make str as an argument to function.

提交回复
热议问题