JavaScript

1.==VS=== in JavaScript

==: check value

===: check value and type

2.JavaScript Prototypes

Every JavaScript object has a prototype. The prototype is also an object.

All JavaScript objects inherit their properties and methods from their prototype.

Creating a Prototype

The standard way to create an object prototype is to use an object constructor function

eg:

  function Person(first, last, age, eyecolor){
  this.firstName = first;

  this.lastName = last;

   this.age = age;

   this.eyecolor = eyecolor;
   }

With a constructor function, you can use the new keyword to create new objects from the same prototype:

eg:

var myFather = new Person("John", "Snow", 50, "black");

The constructor function is the prototype for Person objects.

It is considered good practice to name constructor function with an upper-case first letter.

Last updated

Was this helpful?