News for hackers. Stuff that matters.
Re:Backbone has made me a better programmer by ahoge on Friday August 24, 2012 @08:53PM (#4430615)
It turns -1 (indexOf's "not found" result) into 0 (i.e. something falsy). Any other value is turned into something which isn't 0 (i.e. something truthy).

Basically, it's a smug version of:

    return item.toLowerCase().indexOf(this.query.toLowerCase()) !== -1;
Writing it like this is a lot clearer. Furthermore it even returns `true` and `false` instead of some truthy/falsy integer.

There are no comments on this comment yet.