About closures, I don't understand.

I have read a lot about closures, but I still don"t understand them. Is there an easy-to-understand explanation, and what is its application scenario?

Mar.28,2021

closures are simply cached variables; specific scenarios: function anti-shake and function throttling



javascript
""

closure is a combination of the function and the lexical environment in which the function is declared. The
lexical environment refers to the mapping or reference of the function to variables required by the function that are not in the scope of the function.


the simple understanding of the closure is the return function inside the function

var i = 1;
function a () {
  return function b () {
    console.log(iPP);
  }
}

clipboard.png

Menu