This file contains 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
'use strict'; | |
var Teacher = function (data) { | |
this.name = data.name; | |
this.greet = function (studentCnt) { | |
let promise = new Promise(function (resolve, reject) { | |
if (studentCnt === 0) { | |
reject('Zero students in class'); | |
} else { | |
resolve(`Hello to ${studentCnt} of my favorite students!`); |
This file contains 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
'use strict'; | |
let widgets = ['widget1', 'widget2', 'widget3', 'widget4', 'widget5']; | |
let [a, b, c, ...d] = widgets; | |
console.log(a); // logs widget1 | |
console.log(b); // logs widget2 | |
console.log(d); // logs ['widget4', 'widget5'] |