spacer
Yehuda Shiran February 15, 2001
Class-Based vs. Prototype-Based Languages
Tips: February 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

JavaScript is an object-oriented language not unlike Java and C++. One of the differences between JavaScript and the rest of the gang is that it is a prototype-based language while the other are class-based. A class-based language is based on two fundamental entities: classes and instances.

A class is an abstract data type. It describes a family of objects that have the same set of methods and properties. It also defines these properties and methods. For example, the shape class could represent the set of all shapes in a drawing. An instance is the instantiation of a class. It is one of the members of the family that the class represents. The shape on the top left corner of the page could be an instance of the shape class, representing a single particular shape out of all shapes shown on a drawing.

JavaScript, being a prototype-based language, does not distinguish between classes and instances. It has only objects, which are similar to instances. An object is a real, particular entity. The shape on the bottom right corner of a drawing is an object. You can use an existing object as a template for creating another object. The second object shares the first object's properties and methods. Any object might be used as a prototype for another object. Any object can also specify its own properties and methods, adding or overriding its existing ones.


People who read this tip also read these tips:

Look for similar tips by subject:

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 >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint