guest271314 (2019-05-28T18:49:06.000Z)
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.