Closures in #javascript learn the easy way
▻https://hackernoon.com/closures-in-javascript-learn-the-easy-way-7a7317ce2a07?source=rss----3a8
What are closures?A closure is an inner function that has access to the outer (enclosing) function’s variables — scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variablesIn simple words that is literally what it is, a function inside a function, that relies on variables in the outside function to work .The best way of understanding a concept is by doing it .so let’s have some examples on closures .function doSomeMath()var a=5;var b=4;var sum=a+b;return sum;var theResult = doSomeMath();console.log("The result:", theResult);We do some math here, set up three variables, and add one variable to the other, and return the sum. Now (...)