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
| function funC() { | |
| var lastName = "Tesla"; | |
| function funB() { | |
| var name = "Bose"; | |
| function funA() { | |
| console.log(name, lastName); | |
| } | |
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
| // ====================================== *********** ============================== | |
| // Function Currying | |
| // ====================================== *********** ============================== | |
| function multiply(a, b, c) { | |
| return a * b * c; | |
| } | |
| function multiply(a) { | |
| return (b) => { |
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
| function outerFunction() { | |
| var count = 10; | |
| return function innerFunction() { | |
| console.log(count); | |
| }; | |
| } | |
| var result = outerFunction(); | |
| console.dir(result); | |
| result(); |
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
| function outerFunction() { | |
| var count = 10; | |
| return function innerFunction() { | |
| console.log(count); | |
| }; | |
| } | |
| var result = outerFunction(); | |
| console.dir(result); |
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
| // =================== Scope ======================= // | |
| for (var i = 1; i < 5; i++) { | |
| setTimeout(function() { | |
| console.log(i); | |
| }, i * 1000); | |
| } | |
| for (var i = 1; i < 5; i++) { | |
| (function(j) { |
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
| // =================== Scope ======================= // | |
| for (var i = 0; i < 5; i++) { | |
| setTimeout(function() { | |
| console.log(i); | |
| }, 2000); | |
| } | |
| ----------------------------------------------------- | |
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
| var objA = {foo:"foo"}; | |
| var objB = {bar:"bar"}; | |
| var objC = {baz:"baz"}; | |
| objA.__proto__ = objB; | |
| objB.__proto__ = objC; | |
| console.log(objA.bar); | |
| console.log(objA.baz); |
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
| // Wriatble Demo | |
| var obj = { }; | |
| Object.defineProperty(obj, "property1", { | |
| value: "foo", | |
| writable:true, | |
| enumerable:true, | |
| configurable:true |
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
| var firstName = "John"; | |
| function foo(){ | |
| var firstName = "David"; | |
| lastName = "Sheriff"; | |
| function bar(){ | |
| var lastName = "Stone"; | |
| firstName = "Nicola" | |
| } |
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
| const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]); |
NewerOlder