Last active
June 24, 2021 13:30
-
-
Save vikneshwar/45d24e8b99dbdb088de35bd199d60a2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment