Change "this" when binding element

Change "this" when binding element

We're talking about the same thing...
The only difference is that I was referring to jquery's bind() for events as getting a new scope argument.
<span style="font-family:Prelude, Verdana, san-serif;">
</span><span id="signature"><div style="font-family: arial, sans-serif; font-size: 12px;color: #999999;">-- Sent from my Palm Prē</div>
</span><span style="color:navy; font-family:Prelude, Verdana, san-serif; "><hr align="left" style="width:75%">Daniel Friesen wrote:
Rick Waldron wrote:
> Available, as in the "scope" argument is being retrofitted to an
> existing function, and ONLY to that function.
>
> I don't get what you are talking about a fn.bind() implementation in
> jQuery, or what you mean by available in just one function though.
>
>
> Read ES5.
>
> function.prototype.bind()
I already read ES5, I use portions of ES5 in a number of js server-based
projects already.
However I don't get "ONLY" one function, since the whole point of
.bind() is to bind a `this` onto ONE function with one call. It's not
bind otherwise.
So I don't see any limitation. Unless you are under the
misinterpretation that after you have called .bind() on one function you
have modified that function and bound it's `this`. .bind() doesn't
modify the function, it returns a new one.
From ES5 15.3.4.5 Function.prototype.bind
> The bind method takes one or more arguments, thisArg and (optionally)
> arg1, arg2, etc, and returns a *new*
> function object by performing the following steps:
So this is valid ES5 code.
"use strict";
var a = function() { alert(this); };
var a1 = a.bind("a");
var a2 = a.bind("b");
a(); // Alerts undefined
a1(); // Alerts "a"
a2(); // Alerts "b"
> On Mon, Dec 28, 2009 at 7:43 PM, Daniel Friesen
> <nadir.seen.fire@gmail.com <mailto:nadir.seen.fire@gmail.com>> wrote:
>
> I made a post about how confusing people may find the name bind some
> time ago. Suggested renaming bind to something like event, and keeping
> bind as an alias of course. That was rejected.
>
> I don't get what you are talking about a fn.bind() implementation in
> jQuery, or what you mean by available in just one function though.
>
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire)
> [http://daniel.friesen.name]
>
> Rick Waldron