Skip to content

Instantly share code, notes, and snippets.

@jose4125
Created August 25, 2016 17:56
Show Gist options
  • Select an option

  • Save jose4125/f9d325a9fa7fd7e7ee6f3df36f2bcdaf to your computer and use it in GitHub Desktop.

Select an option

Save jose4125/f9d325a9fa7fd7e7ee6f3df36f2bcdaf to your computer and use it in GitHub Desktop.
console.log('========================== CLASSICAL ================================')
function ClassicalTask(title, complete) {
this.title = title;
this.isComplete = complete || false;
}
ClassicalTask.prototype.complete = function() {
return this.isComplete;
}
ClassicalTask.prototype.msg = function() {
console.log(this.title + ' is ' + (this.isComplete ? 'completed' : 'not completed yet'));
}
var myTask = new ClassicalTask('task1');
var myTask2 = new ClassicalTask('task2', true);
console.log(myTask)
console.log(myTask2)
myTask2.checkCompleteTask = function() {
this.isComplete = true;
console.log(this.complete());
}
console.log(myTask.msg())
console.log(myTask2.checkCompleteTask())
function UrgentClassicalTask(title, complete){
ClassicalTask.call(this, title, complete);
this.typeTask = 'urgent';
}
// UrgentClassicalTask.prototype = ClassicalTask.prototype
// UrgentClassicalTask.prototype = new ClassicalTask()
UrgentClassicalTask.prototype = Object.create(ClassicalTask.prototype);
UrgentClassicalTask.prototype.msg = function() {
console.log(ClassicalTask.prototype.msg.call(this) + ', but this is ' + this.typeTask);
}
var myUrTask = new UrgentClassicalTask('urgent task');
console.log(myUrTask)
console.log(myUrTask.msg())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment