let’s break down how closures work in the context of a currying pattern and lexical scope in JavaScript.
Firstly, a closure is a combination of a function and the lexical environment within which that function was declared. Lexical scope refers to the idea that the scope of a variable is determined by its position within the source code. In JavaScript, functions create closures, and they “remember” the scope in which they were created.