prazanna007
6/12/2016 - 9:44 AM

Use class in ES2015

Use class in ES2015

'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();