Hi Erop,
On Fri, Apr 11, 2014 at 12:35 PM, ???? ???????? <termi1uc1 at gmail.com
<https://mail.mozilla.org/listinfo/es-discuss>> wrote:
>/ 1. Should the AssignmentExpression of DestructuringAssignment always to be
/>/ the Object type?
/>/ ```javascript
/>/ let {length} = "123";
/>/ assert(length, 3);
/>/ ```
/>/ Is this valid?
/>/
/
Yes.
No.
13.2.1.4 Runtime Semantics: Evaluation,
LexicalBinding : BindingPattern Initializer, step 4
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-let-and-const-declarations-runtime-semantics-evaluation
>/
/>/ 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.
No.
13.2.3.7 Runtime Semantics: KeyedBindingInitialization
BindingElement : BindingPattern Initializer_opt, step 4
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-keyedbindinginitialization
You can test this in the web console in a Nightly or Aurora build of
Firefox.
You can test this in traceur or my test implementation
[https://github.com/anba/es6draft]. ;-)
Maybe the final draft will revert this restriction, it was originally
introduced in rev17. It is somewhat annoying, especially for the string
type, because the restriction also applies to spread array elements and
spread calls. For example `[..."abc"]` must now be written as `[...new
String("abc")]` to get the array of code points.
- André
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss