LaserRanger
1 min readJan 9, 2016

--

Lots of good information here, but given that the article’s title is “What is a closure?” I found it too technical. First, we realize that ES6/ES2015 is the standard, but that does not imply, for example, that writing a function using the plain old function() keyword would be obsolete.

Second, why import other JS libraries to demonstrate a closure? In theory, a simpler closure might have sufficed, at least for introductory purposes. Something like this might work:

function testClosure() {

var a = 1;

function closeA() {
return console.log(a);
}

return closeA();

}

testClosure(); // 1

Cool thing is that you have access to the variable ‘a’ outside the scope of testClosure. This is how I understand a simple closure to work.

--

--