I'd be more interested in seeing these techniques applied to Javascript that is coded up with a framework (say jQuery for arguments sake).<p>For example, what is the performance penalty of:<p><pre><code> var arr = [1, 2, 3];
for(var i=0; i < arr.length; i++){ //stuff }
// versus
$.each( arr, function(i, val){ // stuff } );
</code></pre>
Or @ caching:<p><pre><code> $("a").each( function(){
$(this).click(
$(this).find("img").hide();
);
});
// versus
$("a").each( function(){
var targetImage = $(this).find("img");
$(this).click(
$(targetImage).hide();
);
});</code></pre>