This is an example of why even though I love coffeescript, I still frequently write code in raw javascript.
This is the coffeescript I originally had:
pairs = []
for key, value of @data
pairs.push( _(key) + '=' + _(value) )
And this is the javascript it output
var pairs = [], value, _ref1;
_ref1 = this.data;
for (key in _ref1) {
value = _ref1[key];
pairs.push(_(key) + '=' + _(value))
}
I rewrote the coffeescript to be more succint and idiomatic(?)
pairs = for key, value of @data
_(key) + '=' + _(value)
And of course I end up with this code:
var pairs = (function () {
var _ref1, _results;
_ref1 = this.data;
_results = [];
for (key in _ref1) {
value = _ref1[key];
_results.push(_(key) + '=' + _(value));
}
return _results;
}());
Nothing in the semantics has changed (in my head), but to get the more performant code I have to write uglier more explicit coffeescript. I hope that in the near future a compiler would do this for me (perhaps closure already can?).
The more I have to think about what the javascript output is going to be, the more I would rather write in javascript.