Es6 using the filter method and the toLowerCase () method implements insensitive auto-completion;
code show as below:
let list = ["aaaassss", "bbbbffff", "cccciiii", "ddddVVvv"] let str = "ddddvv" let filterList = list.filter(item => item.toLowerCase().indexOf(str.toLowerCase()) !== -1) console.log(filterList ) // ["ddddVVvv"]
Using the filter selected item comprises one of an array of str;
Explanation:
the toLowerCase () method: Unified string to lower case
toUpperCase () method: string to uppercase unified transfer