Please Explain Closures!

Written by nwthomas | Published 2020/01/06
Tech Story Tags: closures | javascript | programming | self-teaching | self-learning | nathan-thomas | beginners | tutorial

TLDR 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.via the TL;DR App

no story

Written by nwthomas | I'm just here for the free food.
Published by HackerNoon on 2020/01/06