Class, Constructor & Prototype


What's the difference between these terms?


Javascript has the following Data-types

•Object  ◦Function/'Method'

Each of the Datatypes represents a =prototype=
thus you have a
Null is a special case

When it comes to inheritance, JavaScript only has one construct: objects. Each object has an internal link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. null, by definition, has no prototype, and acts as the final link in this prototype chain


- - - B a s i c s - - -

Each Object has one or more properties.
Each property consists of a property-key and it's associated value.

 var object1 = {
              name: "First"

So object1 has 1 property
a name property with property-key name and it's associated string VALUE "FIRST"


var myObj = {
         type: 'fancy',
         disposition: 'sunny'

myObj has 2 properties seperated by a comma-,,
a type property with property-key type and an associated string VALUE 'fancy'
a disposition-property with property-key disposition and associated string VALUE 'sunny'.

= = = = = = = = = = = = = = = = = = = = = = =

To create an Object,

you can use the literal notation,

you directly create an Instance of the object, with the
properties being separated by a comma-,

  var myObj = {
        type: 'fancy',
        disposition: 'sunny' 


You create an Object by the construct notation.

First you create an empty Object by way of either
myObj = new Object(); or myObj = {};
and then you attach its properties using the syntax = it's-associated-value ;
( = x ; )


  var myObj = {};
      myObj.type = 'fancy';
      myObj.disposition = 'sunny';


There is also the facility Class construct notation.

The name should then start with a Capital-letter.

  var Person = function( theName, theAge ) { = theName;
         this.age = theAge;
         this.displayInstance = function() {
           console.log("The displayInstance -output-"+
                       "\n============================" +
                     "\n\t name: " + +
                     "\n\t age: " + this.age);
    //now create an Instance of this Class-object
  var myObj = new Person("Classy_Rocker",20);
    //call the Method displayInstance which takes NO parameters
  console.log( myObj );
  //you can run this in try it !!

As you can see i created a function within this constructor,
they now call this function a Method.
So if in near future the course is asking you to create a method you now know
that you have to create
a property-key with an associated value being a function within an Object.


Do object from different classes share that link?
What is that link? Does it have something to do with how all objects are formatted?


It is called the prototype chain.....


What I am trying to understand is what is the nature of that link or chain so I can better understand what all objects have in common. Are you saying that only objects that share the same class share a link or do all objects in my program share a prototype link?