ES3.1 Draft: Array generics

Brendan Eich brendan at
Sat May 31 15:57:54 PDT 2008

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 =,i,a){print(e,i,a, this.z);return e}, {z: 

but this is not:

   var b =,i,a){print(e,i,a, this.z);return e}.bind 

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.


More information about the Es4-discuss mailing list