Joined March 2014
·
Posted to
Object.extend Black Magic
over 1 year
ago
This is pretty sick, nice trick
Posted to
Stop It With the Vars
over 1 year
ago
I agree with the author in that you avoid a lot of potential hoisting errors and your code generally looks cleaner. Additionally if your team consistently declares at the top you always know where to look for the declarations instead of having to search the code. To nitpick from a performance standpoint it is however more performant to use var for each declaration based on my latest tests (4ms to 8ms over 10m loops - Firefox). I personally using one var statement/comma delimited though because it reads cleaner.
I fully agree. Although I'm not a mobile developer a lot of this carries over to what I do. The more moving parts you have the more potential places errors can occur. It's surprising how much you can get a accomplished with very little code. My thoughts are it should be clean, simple and it should just work.