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); }...")
 
Line 1: Line 1:
=Constructor=
<pre>
<pre>
function Person(name, age){
function Person(name, age){

Revision as of 22:17, 20 October 2016

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