Created
August 25, 2016 17:56
-
-
Save jose4125/f9d325a9fa7fd7e7ee6f3df36f2bcdaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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