Please Explain Closures!by@nwthomas
1,227 reads

Please Explain Closures!

January 6th 2020
8 min
by @nwthomas 1,227 reads
tldt arrow
Read on Terminal ReaderPrint this storyRead this story w/o Javascript

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

About @nwthomas
LEARN MORE ABOUT @NWTHOMAS'S EXPERTISE AND PLACE ON THE INTERNET.
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa