Assignment to wrapper objects in strict mode

André Bargull andre.bargull at
Wed May 28 05:08:40 PDT 2014

On 5/28/2014 2:00 PM, Andreas Rossberg wrote:
> On 28 May 2014 13:41, André Bargull <andre.bargull at> wrote:
>>> 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.)
>> That assignment still throws per the current ES6 draft. Following
>> 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.
> But base will already have been converted to a wrapper object at
> PutValue step 6.a.ii before you get to [[Set]].
> /Andreas

The receiver argument in [[Set]] is not the wrapped `base`, but 
`GetThisValue(V)`, here: the empty string "".

More information about the es-discuss mailing list