Uhm, nothing in .bind() that doesn't already exist in JavaScript: The .call() and .apply() methods allow you to call a function in the context of the object passed. I don't see how that's different than what .bind() does.
http://odetocode.com/Blogs/scott/archive/2007/07/05/function-apply-and-function-call-in-javascript.aspxClosure context swapping is an integral part of a functional language like JavaScript...
+++ Rick ---
>>Far more powerful: It gives you even more possibilities, that is true. Monkeypatching (assigning functions to specific instances as "methods") allows some interesting things
>
>As you mention, you can add methods to any object at any time.
>
>You can event add methods to the prototype of native objects such as String, Array, and even Function.
>
>
Prototype framework uses this pattern extensively ... some dislike, we adore !
>
>For example, as
Prototype adds a 'startsWith()' method to the String prototype, any String instance created
after Prototype is loaded inherits this method :
>
>var myString = 'myString';
>alert(myString.startsWith('my')); // displays 'true' in a messagebox
>
>
>> but "more OO" ? You can/have to define your own object description pattern - is that what you mean ?
>
>I mean that everything in the language is an object : a String, an Array, and even a Function.
>You are able to write every instruction in an object-oriented fashion, and even set the definition of the 'this' keyword within a function.
>
>
Prototype framework has a very handy, and famous method .bind() for that purpose (I write 'famous' because it will probably be included as native in the next version of ECMA script, AKA Javascript 2.0).
>Example:
>
>var myString = 'myString';
>var myFunc = function(){alert(this);}.bind(myString); /* now the 'this' keyword within myFunc points to myString */
>myFunc(); /* displays 'myString' in a messagebox */
>
>
>Note : if you have fireFox with FireBug, just copy-paste the code sample above in the extended command window of the console tab while navigating on a page where
Prototype is loaded, such as
http://www.foxincloud.com/demos.php