I went to the Nottingham Geekup last night. The talk was by @firagabeatsrock. A good talk with some important points to watch out for about Javascript.
I am blessed with being fairly au fait with Javascript so was familiar with the subject to a fairly in depth level. I made a couple of good notes however. One was to look at the Javascript performannce tool http://jsperf.com/. As an uber geek I love performance tools. I like nothing more than obsessing over fiendery such as this.
On the subject of performance, he pointed out that when using a for loop, don't refer directly to the length in the loop as javascript checks it every time. There is more to add to this story however. You can make life even worse by reffering to the length of a jquery collection in a for loop. I believe that is particularly slow and I now have the performance tool above to prove it :-)
The other thing I picked up on was a little reminder to look into the ECMAScript5 stuff. Now I have done a little example of the new properties and how they can have method bodies below...
https://gist.github.com/3623706
Ridiculous you say! That can already be achieved! Well, it can to a certain extend but you have very little control over people overriding your object and how you intended it to be used. I was going to go further into this subject but upon looking for supporting information, I found many people had already done a better job of explaining the matter.
Take a peek at this blog and mind that you follow his update for even more interesting little tips....
http://ejohn.org/blog/ecmascript-5-objects-and-properties/
Comments