Prototype Inheritance chain - subclass

by Krishna Ananthi

JavaScript

var Job = function() {
 	  this.pays = true;
}
Job.prototype.print=function(){
  console.log(this.pays ? 'Please hire me' : 'No thanks');
}
var TechJob = function(title,pays){
		Job.call(this);
		this.title= title;
    this.pays=pays;
}
TechJob.prototype = Object.create(Job.prototype);
TechJob.prototype.constructor =  TechJob;

var softwareTechJob = new TechJob('JS Job',true);
var softwareTechJob2 = new TechJob('Java Job',false);

softwareTechJob.print();
softwareTechJob2.print();