let holder, amount; holder = new NumberHolder(10); amount = 2; holder.increaseBy(amount);
let holder, fct; holder = new NumberHolder(10); fct = n => n + 2; holder.changeUsing(fct);
passArrowFunction1() { let holder, fct; holder = new NumberHolder(10); fct = n => n + 2; holder.changeUsing(fct); console.log(holder); } passArrowFunction2() { let holder; holder = new NumberHolder(10); holder.changeUsing(n => n + 2); console.log(holder); } passTradDeclaredFunction() { //declared function let holder, fct; holder = new NumberHolder(10); function increaseByTwo(n) { return n + 2; }; holder.changeUsing(increaseByTwo); console.log(holder); } passTradFunctionExpression() { //function expression let holder, increaseByTwoFct; holder = new NumberHolder(10); increaseByTwoFct = function(n) { return n + 2; }; holder.changeUsing(increaseByTwoFct); console.log(holder); }
Middleware wow!!
class Middleware { static wow() { console.log("wow!!"); } static home(req, res) { console.log(this.name); this.wow(); } } Middleware.home();
app.get('/', Middleware.home);
//app.get('/', Middleware.home);
app.get('/', (req, res) => Middleware.home(req, res));
static home(req, res) { console.log(this.name); Middleware.wow(); }