Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: