Category Archives: Java Script

Make a Class

How to make a class / Constructor in java script. There are 3 ways to do it.

1. Object
Var bob = new Object();
Bob.name = “bob”;
Bob.age = 22;

2. Method/Class
function Person(name,age) {
this.name = name;
this.age = age;
}

3. Constructor/Class/Object
var spencer = {
age: 22,
country: “United States”
};

Source : codeacademy.com