Learning Object Oriented JavaScript programming from ActionScript
I have been doing some JavaScript / Ajax development over the past couple of weeks, and have been trying to figure out the best way to structure my JavaScript and HTML code. One thing that really surprised me when doing research is how many JavaScript projects / examples do not try to encapsulate their code (aside from within script files) or use object oriented programming. Thinking back on this, and given the evolution of JavaScript from a web scripting glue to more of an application programming language, I can understand this, but it did surprise me none-the-less.
Of course, Object Oriented programming in JavaScript can feel a little odd, especially if you are used to more traditional object oriented languages. While prototype based classes can seem weird and quirky, they do allow some amazing flexibility, as well as the use of traditional class based development.
Indeed, this may be one area where long time Flash developers have an advantage when doing JavaScript development, as application development using ActionScript 1.0 requires understanding object oriented programming with JavaScript / ActionScript.
Indeed, I still think that Robin Debreuil’s Building Object Oriented Apps in Flash 5 is one of the best introductions to object oriented programming in JavaScript anywhere. Chapter 12 (Objects and Classes) of Colin Moock’s ActionScript for Flash MX is also an excellent resource on object oriented programming in a prototype based language.
Anyways, if you are interested in doing object oriented JavaScript development, I suggest that you also check out some of the older resources and tutorials around object oriented programming in Flash 5 / ActionScript 1.0.