Constructor Design Pattern in JS

by Rajdeep Chandra

JavaScript

var consTructorPattern = function(firstName,lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
  
  this.fullName = function(){
    return "My Name is " + this.firstName + " " + this.lastName;
  }
}

var newObject1 = new consTructorPattern('rajdeep', 'chandra')
document.write(newObject1.fullName());

var newObject2 = new consTructorPattern('subhodeep', 'chandra')
document.write(newObject2.fullName());