Constructor Pattern

Creating objects from functions

				
					let Study = function (course, level) {
  this.course = course;
  this.level = level;

  this.courseLevel = function () {
    console.log(this.course + " is for " + this.level);
  };
};

let study1 = new Study("Javascript", "Beginners");
let study2 = new Study("Advanced Javascript", "Professionals");
let study3 = new Study("ES new concepts", "Proficients");

study1.courseLevel();
study2.courseLevel();
study3.courseLevel();

//Output
// Javascript is for Beginners
// Advanced Javascript is for Professionals
// ES new concepts is for Proficient

				
			

Leave a Comment