Re:Destructuring Assignment in ECMAScript 6
by xhrpost on Thursday August 15, 2013 @03:45PM
(#6220112)
Definitely looking forward to this as well as other new ES6 stuff. There's something else I feel I could use perhaps even more but I haven't seen it in any of the ES* updates. I'm a huge advocate of DRY and it bothers me when I have to code something like:
I can and sometimes just make an extra variable above for a long prop list like this but that adds an extra line. I guess what I would like would be some sort of implied line limited scope:
_1 referring to the first mentioned value in the immediate parent statement.
[ Parent
| on HN ]
Re:Destructuring Assignment in ECMAScript 6
by ptgloden on Thursday August 15, 2013 @03:56PM
(#6220181)
In ES6, you can write more terse immediately invoked function expressions. So you could use
var a = (prop => prop > 5 ? prop : whatever)(objImUsing.prop.someLongName)
rather than var a = (function (prop) { return prop > 5 ? prop : whatever })(objImUsing.prop.someLongName)In older versions of Firefox, you could write:
var a = #1=objImUsing.prop.someLongName > 5 ? #1# : whatever;
but it's been killed since Firefox 12:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shar...