4 ms·
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 t
by xhrpost 13y ago
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:
var a = objImUsing.prop.someLongName > 5 ? objImUsing.prop.someLongName : whatever;
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:
var a = objImUsing.prop.someLongName > 5 ? _1 : whatever;
_1 referring to the first mentioned value in the immediate parent statement.
- ptgloden 13y agoIn 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)
- mook 13y agoIn 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/Sharp_variables_in_JavaScript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shar...