spacer

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

home / experts / javascript / column34


Inheritance through Prototypes

Developer News
Intel's Building Blocks Thread Open Source
What Lies Ahead for SOA?
Novell Turns ICE Into Kablink

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


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Simple Comments Release Notes: v.960 · Adding Client Capabilities to Server Controls Using the ASP.NET AJAX Control Toolkit · How to Create an Ajax Autocomplete Text Field: Part 10
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Data Corruption: Dedupe's Achilles Heel · AccessLine Launches SOHO VoIP Product with Costco · Cisco to Acquire Pure Networks


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

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