Difference between revisions of "Constructors"

From rbachwiki
Jump to navigation Jump to search
(Created page with "<pre> 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); }...")
(No difference)

Revision as of 22:16, 20 October 2016

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);
  }
}
var person = new Person("robert",24);
person.display();