News for hackers. Stuff that matters.
Re:Backbone has made me a better programmer by kevincennis on Friday August 24, 2012 @08:55PM (#4430621)
`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())`

There are no comments on this comment yet.