Hysterical!!! Thanks for that laugh!!! On Dec 1, 2011 9:01 AM, "Victor" <[email protected]> wrote:
> 1. Declaration with value assignment > 2. Declare loop variables and cache length inside of for() - this can > increase performance <http://jsperf.com/caching-array-length/67> - > caching length outside of for() is slower in almost all results (all > Firefox and Safari, IE9 and some Chrome results) > 3. Unnecessary return values > > Example can be rewritten as: > SelectParser.select_to_array = function(select) { > var parser = new SelectParser(), _ref = select.childNodes; > for (var _i = 0, _len = _ref.length; _i < _len; _i++) { > parser.add_node(_ref[_i]); > } > return parser.parsed; > }; > > yet another real example: > > CoffeeScript (with use of Prototype): > class Chosen extends AbstractChosen > ... > no_results_clear: -> > nr = null > nr.remove() while nr = @search_results.down(".no-results") > > CoffeeScript translated to JavaScript: > Chosen.prototype.no_results_clear = function() { > var nr, _results; > nr = null; > _results = []; > while (nr = this.search_results.down(".no-results")) { > _results.push(nr.remove()); > } > return _results; > }; > > and pure JavaScript: > var Chosen = Class.create(AbstractChosen, { > ... > no_results_clear: function() { > this.search_results.select(".no-results").invoke("remove"); > }, > ... > }); > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/prototype-scriptaculous/-/FBTDmhOjgWoJ. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
