javascript includes() case insensitive

前端 未结 6 1429
臣服心动
臣服心动 2020-12-14 05:07

lets say I have an array of filter strings that I need to loop and check against with other passed in string.

var filterstrings = [\'firststring\',\'secondst         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 05:55

    Fixed case sensitivity issue using toLowerCase(). It turns all the string to lower case while comparing.

    var product=productList.filter((x) => x.Name.toLowerCase().includes(("Active").toLowerCase()))
    

提交回复
热议问题