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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow

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:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark