View Single Post
Old 11-20-2012, 05:37 PM   PM User | #5
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,860
Thanks: 9
Thanked 290 Times in 286 Posts
Dormilich is on a distinguished road
Quote:
Originally Posted by rnd me View Post
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).
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote