Summary JavaScript is not only at the heart of popular Ajax frameworks, but is also one of the scripting languages that work well with Java on the server, and the next-genereration JavaScript is the foundation of ActionScript, the language behind Adobe's Flex framework. While JavaScript is an object-oriented language, instead of classes, it uses the concept of a prototype as the basic building-block of its object-model. In a recent blog post, Prototype & Object Oriented JavaScript, Josh Davis explains that: Prototype is a built-in JavaScript object which is a child of all objects and is used to create properties and methods for all instances of an object. You can use it on your JavaScript objects to create classes with externally defined methods... You can also add methods to built-in JavaScript objects... You can also use prototype to create a class which extends another... Davis shows several code examples of how to implement polymorphism and inheritance with prototypes. What do you think of the prototype-based approach to OO, especially when compared with the class-based approaches used in Java, C++, or Ruby?
Instead of classes, JavaScript uses prototypes as the basic building blocks of its object model. In a recent blog post, Josh Davis explains how prototypes compare to classes, and shows how to use the basic object-oriented techniques of inheritance and polymorphism in a prototypes-based language.
http://www.wujianrong.com/mt-tb.cgi/5282