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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37234-2c078.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37234-2c078.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?