guest271314 (2019-05-28T18:49:06.000Z)
>
> ```
>> let obj = {otherData: "other data"};
>> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
>> ```
>
> I don't understand this.
>
>
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping `{}` around ```from`` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more
type-checkable (for typed variants of the language), more reminiscent of
existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

This proposal would resolve the issue of currently, in general, having to
write the property name twice.



On Tue, May 28, 2019 at 2:47 PM Bob Myers <rtm at gol.com> wrote:

> ```
>> let obj = {otherData: "other data"};
>> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
>> ```
>>
>
> I don't understand this.
>
>
>> Alternatively there are various approaches which can be used to get only
>> specific properties from an abject and set those properties and values at a
>> new object without using destructing assignment.
>>
>> Using object rest and ```reduce()```
>>
>> ```let obj = {otherData: "other data", ...["firstName",
>> "lastName"].reduce((o, prop) => (o[prop] = user.profile[prop], o), {})};```
>>
>> `Object.assign()`, spread syntax and `map()`
>>
>> ```let obj = Object.assign({otherData: "other data"}, ...["firstName",
>> "lastName"].map(prop => ({[prop]:user.profile[prop]})));```
>>
>
> As the words "syntactic sugar" in the subject of the thread make clear,
> the OP is not merely looking for ways to assign one object's property into
> another--there are many ways to do that. He's looking for a terser, moire
> elegant way to do it, which hopefully would be moire semantic, less
> bug-prone, more type-checkable (for typed variants of the language), more
> reminiscent of existing syntax such as deconstruction, and potentially more
> optimizable by engines.
>
> Bob
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190528/77775cc0/attachment.html>
guest271314 at gmail.com (2019-05-28T19:00:33.907Z)
> ```
> let obj = {otherData: "other data"};
> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Not certain if destructuring assignment can currently be golfed more within the scope of the current JavaScript implementation, that is, without writing the property name twice, though might be possible.

Recollect a nodejs ability to write something similar to 

```
var obj = {} = {};
```

within the scope of destructuring assignment, though not sure if that is relevant to this proposal.

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping of `{}` around ```[prop,[...props]] from source``` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more type-checkable (for typed variants of the language), more reminiscent of existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

The language "type-checkable" does not appear at the original proposal.

This proposal would resolve the issue of currently, in general, having to write the property name twice.
guest271314 at gmail.com (2019-05-28T18:54:54.911Z)
> ```
> let obj = {otherData: "other data"};
> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping of `{}` around ```[prop,[...props]] from source``` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more type-checkable (for typed variants of the language), more reminiscent of existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

The language "type-checkable" does not appear at the original proposal.

This proposal would resolve the issue of currently, in general, having to write the property name twice.
guest271314 at gmail.com (2019-05-28T18:53:45.624Z)
> ```
> let obj = {otherData: "other data"};
> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping of `{}` around ```[prop,[...props]] from source``` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more

type-checkable (for typed variants of the language), more reminiscent of
existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

This proposal would resolve the issue of currently, in general, having to
write the property name twice.
guest271314 at gmail.com (2019-05-28T18:53:33.669Z)
> ```
>> let obj = {otherData: "other data"};
>> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
>> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping of `{}` around ```[prop,[...props]] from source``` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more

type-checkable (for typed variants of the language), more reminiscent of
existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

This proposal would resolve the issue of currently, in general, having to
write the property name twice.
guest271314 at gmail.com (2019-05-28T18:53:10.186Z)
> ```
>> let obj = {otherData: "other data"};
>> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
>> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping of `{}` around ```[prop,[...props]] from``` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more

type-checkable (for typed variants of the language), more reminiscent of
existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

This proposal would resolve the issue of currently, in general, having to
write the property name twice.
guest271314 at gmail.com (2019-05-28T18:52:04.116Z)
> ```
>> let obj = {otherData: "other data"};
>> ({firstName:obj.firstName, lastName:obj.lastName} = user.profile);
>> ```
>
> I don't understand this.
>
>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

> He's looking for a terser


Is the proposal to golf destructuring assignment?

The proposed destructuring assignment syntax example is 25 characters less
than the non-destructing assignment example, which is terser.

One observation about the proposed syntax is that the values set at the
target object would be set from the identifier on the left side of
```from``` which is similar to

```
var o = {x:1};
console.log(o.x = 2); // 2
```

though how will the property name be set at the object at target object
instead of `{"2":2}`? How does the engine know when the expected result is
```{"x":2}``` and not ```{"2":2}```? Certainly such functionality can be
designed, for example, using the proposed key word ```from```.

If more terse code is one of the features that would be achieved, why are
the wrapping `{}` around ```from`` necessary?

> moire elegant way to do it,

"elegant" is subjective

> which hopefully would be moire semantic, less bug-prone, more

type-checkable (for typed variants of the language), more reminiscent of
existing syntax such as deconstruction, and potentially more optimizable by
engines.

What is bug prone about the code examples at OP?

This proposal would resolve the issue of currently, in general, having to
write the property name twice.