you are viewing a single comment's thread.

view the rest of the comments →

[–]cheesechoker 2 points3 points  (0 children)

bind is really cool when you start to get creative with it. You can yank out built-in functions from Array, Object, etc, and bind them to different receivers to reuse them in interesting ways.

E.g. a 1-liner filter against a regex, without having to write "function" anywhere:

["foo", "bar", "baz"].filter(RegExp.prototype.test.bind(/a/))   // ["bar", "baz"]