Skip to content

Instantly share code, notes, and snippets.

@YoneMoreno
Last active November 5, 2017 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoneMoreno/c0941fce047872b23a92e112c388fd20 to your computer and use it in GitHub Desktop.
Save YoneMoreno/c0941fce047872b23a92e112c388fd20 to your computer and use it in GitHub Desktop.
var Task = require('./taskConstructorPattern');
var task1 = new Task('create a demo for constructors');
var task2 = new Task('create a demo for modules');
var task3 = new Task('create a demo for singletons');
var task4 = new Task('create a demo for prototypes');
task1.complete();
task2.save();
task3.save();
task4.save();
var Task = function(name){
this.name=name;
this.completed=false;
}
Task.prototype.complete = function () {
console.log('completing task: ' + this.name);
this.completed=true;
};
Task.prototype.save = function () {
console.log('saving Task: ' + this.name);
};
module.exports = Task;
'use strict';
class Task {
constructor(name){
this.name=name;
this.completed=false;
}
complete() {
console.log('completing task: ' + this.name);
this.completed=true;
};
save() {
console.log('saving Task: ' + this.name);
};
}
var task1 = new Task('create a demo for constructors');
var task2 = new Task('create a demo for modules');
var task3 = new Task('create a demo for singletons');
var task4 = new Task('create a demo for prototypes');
task1.complete();
task2.save();
task3.save();
task4.save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment