Skip to content

Instantly share code, notes, and snippets.

'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']
'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!`);