Quote:
Originally Posted by rnd me
less obvious in my code is what's being bound.
it's not max(), it's apply().
check this out:
Code:
max=String.apply.bind(Math.max, 0);
max([1,2,3]) // ===3
yeah, that's weird, but it works because apply() doesn't care what is in front or behind it. it's a generic. i guess you can think of it as being "loose"; it doesn't care what function, this, or arguments it's hooked up with. heh.
|
it made "click" here. what I didn’t see is that the
Math.max in front of
apply.bind() is just the source for
apply() and hence the first parameter is the
this for
apply() and the second the
this for
bind() (which is irrelevant as there is no
this in a static function).