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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s