Tag Archives: tutorial

Advanced JavaScript Lessons for the 21st Century

Javascript, as you may know, has not changed very much since it first appeared back in the 90’s. Over the past couple of years, however, many people have been pushing to give the language an overhaul. It could take another couple of years before these new additions are in place in all major browsers (who knows), but things WILL change – and hopefully for the better. The next version of JavaScript should be JavaScript 2.

JavaScript started off pretty popular, it kicked Vbscript out of the game (not long after Microsoft introduced it). But after a while it also gained a lot of critics (all languages do!). One reason (in my view) is because many people coded poorly in JavaScript, and spat out horrible looking code. Another is because the Browser DOM API which JavaScript was used with was poor (it is still not great, but work is being done here too). JavaScript was the only real option available (and it still is). However, over the past few years, many serious programmers introduced new ways of using JavaScript – ways which are much more pretty, and powerful. In fact, these new ways have made it clearer what was actually missing from the language to start with, what was already there but overlooked by many, and what would make it better for the future.

The founder of JavaScript, Brendan Eich, still appears to be one of the major forces in the future of the Language. You can keep up-to-date by reading his blog over at weblogs.mozillazine.org/roadmap/.

Anyway, on to the main purposed of this post. I found an excellent Advanced JavaScript presentation which John Resig has made public (he actually presented this at a recent Web 2.0 expo, in New York). In my opinion, this presentation is first class.

The presentation aims to teach you how to understand the following code from the Prototype Library:

// The .bind method from Prototype.js 
Function.prototype.bind = function(){ 
  var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); 
  return function(){ 
    return fn.apply(object, 
      args.concat(Array.prototype.slice.call(arguments))); 
  }; 
};

Have fun, I did!