Prototypes

The prototype object was introduced in JavaScript 1.1 as an intrinsic object that simplifies the addition of custom properties and methods to existing objects. When we begin to create objects and prototypes, we are getting into the real nuts and bolts of JavaScript and will be able to create some powerful functionality. An example of how the prototype object works is fairly simple: If it is asked for a method or property that it does not contain, it checks the prototype of the class that created it. It will continue to follow this chain of looking at the parent objects if it does not find the property or method that was called. As a last resort, it will find the Object.prototype (which is the object that creates all objects), but most ...

Get Ajax for Web Application Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.