Yesterday, couple of my friends and I were discussing about a CoffeeScript topic. In short, given the following code in CoffeeScript:
1 2 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
As you see here, the prototype method definitions use the prefix
Cat.prototype repeatedly. Which could be compressed using closure as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
This closure form is for sure less bloated than the one produced by CoffeeScript. And on IE7, each
Cat.prototype lookup takes about a microsecond, so, the closure form quite literally yields a micro-second-optimization! When one zooms into such micro-optimizations, other bigger fishes are easily missed.