|
February 23, 2001 Defining Instances Tips: February 2001
Yehuda Shiran, Ph.D.
|
|
As opposed to Java, which is a class-based language, JavaScript is a prototype-based language. This difference is reflected everywhere. The term instance, for example, has a specific meaning in class-based languages. An instance is an individual member of a class. It is an implementation of the class definition. In JavaScript, "instance" does not have this technical meaning, because there is no such difference between classes and instances. However, instance can be used informally to mean an object created using a particular construction function. In the following example:
How would the above example look in a class-based language? In Java, it is translated into something like that:
People who read this tip also read these tips: Look for similar tips by subject: |