Seven JavaScript Techniques You Should Be Using Today
Written by on April 25th, 2007 in Ajax News.
Dustin Diaz has written an article on the Seven JavaScript Techniques You Should Be Using Today.
Dustin delves into:
- Branch when possible: When performance matters, it’s often advisable to branch out your functions in a way that ensures processor-intensive or memory-hungry tasks won’t be frequently repeated. One of the most common scenarios where this situation can arise is handling browser differences
- Make Flags: var w3 = !!(document.getElementById && document.createElement); The not operators (!!) simply perform a Boolean conversion. The first operator changes the type of the object on the right to a Boolean, and then the second will just reverse whatever the first returned
- Make bridges: function getUserNameByIdBridge (e) { getUserNameById(e.id); }
- Try Event Delegation: Read Christian Heilmann’s work
- Include methods with your getElementsByWhatever: Use callbacks. getElementsBySelector(’#example p a’, function(el) {}
- Encapsulate your code:
(function() { ..... })();
Source: Ajaxian
Original Article: http://ajaxian.com/archives/seven-javascript-techniques-you-should-be-using-today