3 ms·
`indexOf` returns -1 if there's no match. Bitwise NOT on -1 will give you 0 -- for any other number, it'll return a truthy value. It's the same as: `return i
by kevincennis 14y ago
`indexOf` returns -1 if there's no match.
Bitwise NOT on -1 will give you 0 -- for any other number, it'll return a truthy value.
It's the same as:
`return item.toLowerCase().indexOf(this.query.toLowerCase()) !== -1`
If you're really dead set on doing things this way, it's safer to prefix with !! to coerce a real boolean:
`return !!~item.toLowerCase().indexOf(this.query.toLowerCase())`