//pure functions //given a input will always return a same output //will not cause side effects const add = (a, b) => a + b; //impure function 1 const magicLetter = "*"; const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`; //impure function 2 const fetchLoginToken = externalAPI.getUserToken; //Closure //Ex: //Hoisting //Ex: console.log(x); // undefined var x = 2; console.log(x); //2 //let and const are hoisted but not assigned a value so will throw error //Ex: var x = 10; { console.log(x); //throws undefined error let x = 20; } //IIFE // Why IIFE var x = 10; console.log(x); (function () { console.log(x); var x = 2; console.log(x); })(); // .call .apply .bind // ES6 Features // Node Architecture if (new Boolean(false)) { console.log("TEST"); } //function hoisting foo(); var foo = function () { console.log("TEST"); }; //Promises let data = { name: "viknesh", }; let data_1 = data; data_1.name = "xyz"; console.log(data); //first class functions // node advantage vs disadvantage