Clarify the destructuring syntax

Till Schneidereit till at tillschneidereit.net
Fri Apr 11 04:50:24 PDT 2014


When in doubt, listen to André when it comes to spec details. So yes, it's
valid in Firefox, but invalid per spec. Also, I agree that Firefox's
behavior makes more sense, so I hope this'll change.


On Fri, Apr 11, 2014 at 1:45 PM, Егор Николаев <termi1uc1 at gmail.com> wrote:

> @Till Schneidereit. Sorry, but I am misunderstand you.
> Are you saying that this:
> ```javascript
> let {text: {length}} = {text: "123"};
> ```
> is valid?
>
> I am testing this behavior in traceur and FireFox.
> traceur says me that this is invalid
> spec says me that this is invalid
> FireFox 30.0a2 says to me that this is fine and quite logical.
>
>
> On Fri, Apr 11, 2014 at 2:38 PM, Till Schneidereit <
> till at tillschneidereit.net> wrote:
>
>> Hi Erop,
>>
>>
>> On Fri, Apr 11, 2014 at 12:35 PM, Егор Николаев <termi1uc1 at gmail.com>wrote:
>>
>>> 1. Should the AssignmentExpression of DestructuringAssignment always to
>>> be the Object type?
>>>  ```javascript
>>> let {length} = "123";
>>> assert(length, 3);
>>> ```
>>> Is this valid?
>>>
>>
>> Yes.
>>
>>
>>>
>>> If it is:
>>> 2. Should the result of Get(obj, name) always be the Object type if
>>> DestructuringAssignmentTarget is an ObjectLiteral or an ArrayLiteral?
>>> According the spec 12.14.5.4 step 4.b this expression is invalid:
>>> ```javascript
>>> let {text: {length}} = {text: "123"};
>>> assert(length, 3);
>>> ```
>>>
>>
>> Yes.
>>
>> You can test this in the web console in a Nightly or Aurora build of
>> Firefox.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140411/be52213a/attachment-0001.html>


More information about the es-discuss mailing list