Menu

Post image 1
Post image 2
1 / 2
0

Some basic understanding of closure🎈

DEV Community·E_Chronosands::·20 days ago
#k0RBBQE4
Reading 0:00
15s threshold

About closure Quoting Wikipedia: In computer science, a closure, also known as a lexical closure or function closure, is a technique for implementing lexical binding in programming languages ​​that support first-class functions. In implementation, a closure is a structure that stores a function (usually its entry address) and an associated environment (equivalent to a symbol lookup table). The above description is very professional. I prefer to describe it this way: the ability of a function to remember and access variables in the scope in which it was defined . This characteristic is often used extensively in functional programming languages. This type of code is typically written in JavaScript: Why can the count variable still be accessed outside the outer function? Because the outer function returns an inner function, and the inner function holds a reference to count, the local variable count will not be destroyed after outer finishes executing.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More