Jason Rowe

Be curious! Choose your own adventure.

JavaScript: Create Advanced Web Applications With Object-Oriented Techniques

I just started working with OOP in javascript and found this article very informative. The section on prototypes was very helpful as I have been digging around in the YUI library lately and found that area confusing. JavaScript: Create Advanced Web Applications With Object-Oriented Techniques

The article has lots of examples if you click on the figure links. Here was a useful one on Inheriting from a Prototype:


Inheriting from a Prototypefunction GreatDane() { }
var rover = new GreatDane();
var spot = new GreatDane();
GreatDane.prototype.getBreed = function() {
return “Great Dane”;
};
// Works, even though at this point
// rover and spot are already created.
alert(rover.getBreed());
// this hides getBreed() in GreatDane.prototype
spot.getBreed = function() {
return “Little Great Dane”;
};
alert(spot.getBreed());
// but of course, the change to getBreed
// doesn’t propagate back to GreatDane.prototype
// and other objects inheriting from it,
// it only happens in the spot object
alert(rover.getBreed());


Posted

in

by

Tags:

Comments

One response to “JavaScript: Create Advanced Web Applications With Object-Oriented Techniques”

  1. senthil Avatar
    senthil

    right on ! this is a very good article

Leave a Reply

Your email address will not be published. Required fields are marked *