Assignment to wrapper objects in strict mode

André Bargull andre.bargull at udo.edu
Wed May 28 04:41:14 PDT 2014


> Apparently, there has been a semantic change between ES5 and ES6
> regarding assignment to wrapper objects in strict mode. That is,
>
>    'use strict'; "".x = 0
>
> would throw in ES5, but AFAICS, no longer does in ES6. Was this change
> discussed? What is the rationale?
>
> (FWIW, current implementations disagree about this: e.g., V8 and SM
> don't throw, JSC does.)
>
> /Andreas

That assignment still throws per the current ES6 draft. Following 
6.2.3.2 PutValue to 9.1.9 [[Set]], step 4.d in [[Set]] creates a dummy 
data descriptor when no inherited property was found (that way the 
condition in step 5 will evaluate to true), and step 5.b in [[Set]] 
returns false if the receiver is not an object. At that point we're back 
in PutValue, and step 6.d in PutValue will now throw TypeError in strict 
mode.


- André


More information about the es-discuss mailing list