spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column34


Inheritance through Prototypes

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

We touched upon JavaScript's object-oriented nature several times in our previous columns. In fact, the words "Java" and "JavaScript" are often associated with OO programming and OO languages. In this column we show you how to take advantage of some of the object-oriented characteristics of the language. In particular, we show you how to extend objects with the prototype property.

You can extend two types of objects. First, you can extend a class of objects. You can enhance, for example, the Array class, thus affecting all existing and future instances of the Array class of objects. Secondly, you can extend a particular instance of an object, not affecting any other objects of the same class. There are several ways to extend an object. You can add properties, methods, and other objects. When adding a new object to an existing one, all of the new object's properties and methods are added. Two objects can be extended by a common third object. They "inherit" the characteristics of the same object.

In this column you'll learn:


We demonstrate the inheritance concept by two animation scripts we presented in one of our previous column, JavaScript Animations, Part II. We modified the simple animation and the nested animation scripts to inherit a common object. At this point, you may view both the code for simple animation as well as the code for the nested one. You may also view the code for the shared animation library, or download its zipped version.

More Resources from Doc JavaScript
Columns Popular Columns Tips Tools
Latest Columns
41-50 | 31-40 | 21-30
11-20 | 1-10
Working with Windows
JavaScript and Frames
Bookmarklets
Random Tips
Personalized Tips
RSS Channels
Menu Builder
Rollover Builder
Rotation Builder
Reference Tip Categories (want one?)
Links
For Your Site
Did you learn something? Do you like this site? Please link to us!

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji


All Rights Reserved. Legal Notices.
Created: January 18, 1999
Revised: January 18, 1999

URL: http://www.webreference.com/js/column34/