JavaScript 'Constructor' Pattern

by Himanshu Dhiraj Mishra

JavaScript

var employeeConstructor = function(name, age, position){
	this.name = name;
  this.age = age;
  this.position = position;
 	this.printEmployee = function(){
        console.log(this.name+", "+this.age+", "+this.position);
    }
}

var employee1 = new employeeConstructor("Siri",25,"DotNet Dev.");
var employee1 = new employeeConstructor("Alexa",27,"Java Dev.");

employee1.printEmployee();
employee1.printEmployee();