
JavaScript Closures
A closure is a combination of a function bundled together (enclosed) with references to its surrounding state (the lexical scope). Lexical scoping The stance of a variable asserted in the source code denotes its scope in syntactic figuring. For example:
1 2 3 4 5 6 7 8 9 10 11 12 |
let name = 'John'; function greeting() { let message = 'Hi'; console.log(message + ' '+ name); } |
In this example: The variable name is a global variable. It can be accessed Continue Reading »