---
title: "Comment by sascha sascha on \"You (may not) Know JS\" | Hashnode"
description: "Nice article, good visualizations. But your explanation of closures is not correct and it happens a lot. You are describing lexical scoping as far as I remember"
url: "https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761"
---

[Discussion](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a)

Comment [You (may not) Know JS](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a)

[sascha sascha](https://hashnode.com/@Sascha10k)

[Apr 14, 2021](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761)

Nice article, good visualizations.

But your explanation of closures is not correct and it happens a lot. You are describing lexical scoping as far as I remember.

A closure "closes" the function.

```
function a() {
 let me = 0;
 function b(){
  me = 1;
 }

 return b;
}

let fA = a(); // function is still "in the memory"
fA(); // now it is getting removed "from the memory"
```

The final execution of b() by calling fA() closes a(). So the name isn't even that bad.

[David Morais](https://hashnode.com/@DavidMorais)

[Apr 14, 2021](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761#reply-6076e929a3407a32d7041829)

Hey 👋 Tks for reading and comenting

My example is minimalist, at best, but is still a closure, at least according to MDN's explanation. I have access to the outer function/scope variables while inside an inner function. I just happen to be in a theoretical global scope

Your example is correct, but I think fA() will remain in the memory heap until it's garbage collected.

[Tony B](https://hashnode.com/@octree)

[Apr 14, 2021](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761#reply-6076fa5aa3407a32d7041afb)

[David Morais](https://hashnode.com/@DavidMorais)

I don't think you are correct about your example being a closure - even according to MDN's explanation.

"a function bundled together (enclosed) with references to its surrounding state"

You took the bit about surrounding state, but ignored the bit about a function being bundled together/enclosed. Your example is just looking at global state - that isn't bundled, that is open to everyone to mess with. :)

I would update it anyway for teaching purposes, as the rest of your article is excellent IMHO.

[sascha sascha](https://hashnode.com/@Sascha10k)

[Apr 14, 2021](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761#reply-6076ffc24155da32fc83aa1b)

[David Morais](https://hashnode.com/@DavidMorais)

yes it is still there I think therefore the quotes. as [Tony B](https://hashnode.com/@octree) said I would change it because the word closure is about the enclosed state and not purely about scope and your article is very good.

[David Morais](https://hashnode.com/@DavidMorais)

[Apr 14, 2021](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761#reply-607714c94155da32fc83acf6)

I'll update it later today, but I'm still in doubt wether this implicit global scope doesn't count as an enclosure. [Tony B](https://hashnode.com/@octree) thanks for the read and the feedback 🤘🤘

Thank you both

EDIT: Updated both snippets.
