Closure
TDLR
closure 可以讓 function 保有自己的變數或者說是狀態
let cupCount = 0
const cupCounter = () => {
const inc = () => {
cupCount += 1
}
}
TDLR
closure 可以讓 function 保有自己的變數或者說是狀態
let cupCount = 0
const cupCounter = () => {
const inc = () => {
cupCount += 1
}
}