On May 31, 2008, at 3:37 PM, Douglas Crockford wrote:
> The hazards of the misbinding of this are
> a particular problem for mashup platforms, so the use of the
> thisObject
> parameter will not be allowed in strict mode.
So IIUC, in ES3.1 strict mode, given
var a = [1,2,3];
this is an error:
var b = a.map(function(e,i,a){print(e,i,a, this.z);return e}, {z:
42});
but this is not:
var b = a.map(function(e,i,a){print(e,i,a, this.z);return e}.bind
({z:42}));
Why is it ok to do something one (novel) way, but not another
(existing in 3 of 4 browsers) way?
That bind allocates an extra object may give the second way greater
integrity, but unless the function is stashed somewhere and called on
a different thisObject by other code, the above forms are equivalent.
The map implementation will only call the passed in function, and
only with the given or bound thisObject, once per existing (non-hole)
array element.
That bind require an extra (function) object to be allocated is
undesirable overhead, in the absence of threats.
/be
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss