paint-brush
Please Explain Closures!by@nwthomas
1,240 reads
1,240 reads

Please Explain Closures!

by nwthomas8mJanuary 6th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A closure is an invisible compartmentalization of variables that are accessible to your code at various levels (e.g. the global scope, local function scope) JavaScript does this automatically, so all we need to do is understand it. JavaScript has created multiple scopes for your code behind the scenes; there is a global scope with the global global variable and local scope accessible in them. The ability of closures to access all variables in scope at the time of the function's creation could be used later when the function is used elsewhere, even another file.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Please Explain Closures!
nwthomas HackerNoon profile picture
nwthomas

nwthomas

@nwthomas

I'm just here for the free food.

About @nwthomas
LEARN MORE ABOUT @NWTHOMAS'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

nwthomas HackerNoon profile picture
nwthomas@nwthomas
I'm just here for the free food.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Polywork
Rootdaemon
Learnrepo
Freesion
Tefter
Pipfeed