Why Closures Are Important?

Why Closures Are Important?

Closures are important because they control what is and isn't in scope in a particular function, along with which variables are shared between sibling functions in the same containing scope.

What is the point of closures?

The purpose of closures is simply to preserve state; hence the name closure - it closes over state.

What are the advantages of using a closure?

1. By using a closure we can have private variables that are available even after a function task is finished. 2. With a function closure we can store data in a separate scope, and share it only where necessary.

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.