Constructors

From rbachwiki
Revision as of 22:23, 20 October 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Constructor

function Person(name, age){
  this.name = name;
  this.age=age;
  this.display=function(){
    console.log("My name is " + name);
    console.log("My age is "+ age);
  }
}
// create a new Object
var person = new Person("robert",24);
person.display();