Zum Hauptinhalt springen
LIVE
CVSS 6.5CVE-2026-111315 | The Smaily Connect plugin for WordPress is vulnerable to Insecure Direct Object Reference in versions up to, and including, 3.24.0 This is due to the smaily_get_edit_user_id() function reading an attacker-controlled $_GET['user_id'] parameter without performing any ownership or capability check, and then feeding that id into smaily_get_userdata() (which calls get_user_meta()) when rendering the WooCommerce My Account 'edit-account' form via the smaily_print_CVSS 6.4CVE-2026-137713 | Webmin through 2.670 before ae8feb1 allows XSS via an SVG attachment in a mail queue, relevant if an authenticated user uploads an SVG document and an administrator views it.CVSS 6.9CVE-2026-137678 | A security vulnerability has been detected in code-projects Online Job Portal 1.0. Affected by this issue is some unknown functionality of the file Admin/InsertUser.php. Such manipulation of the argument txtUserName/txtPassword leads to sql injection. The attack can be launched remotely. The exploit has been disclosed publicly and may be used.CVSS 5.3CVE-2026-137703 | Flask-AppBuilder before 5.3.1 contains a path traversal vulnerability in ImageManager.save_file that allows authenticated users to write image files outside IMG_UPLOAD_FOLDER via unsanitized multipart filenames. Attackers with add or edit permission on a ModelView with an ImageColumn can upload filenames containing ../ segments to create or overwrite image files like static assets.CVSS 6.1CVE-2026-130039 | The LiteSpeed Cache plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'REQUEST_URI' parameter in all versions up to, and including, 7.9.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page. Successful exploitation requires comments to be open, a comment author name containinCVSS 6.1CVE-2026-136206 | The Export Products, Orders & Customers for WooCommerce plugin for WordPress is vulnerable to Reflected Cross-Site Scripting via the 'start_date' parameter in all versions up to, and including, 2.4.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that execute if they can successfully trick a user into performing an action such as clicking on a link. SucCVSS 9.4CVE-2026-137706 | Smart Portal developed by Direk Tech has a Missing Authorization vulnerability. Authenticated remote attackers can add a specified account to the Active Directory Domain Admins group, thereby obtaining domain administrator privileges.CVSS 8.7CVE-2026-137705 | Smart Portal developed by Direk Tech has an Arbitrary File Read vulnerability.Unauthenticated remote attackers can exploit Relative Path Traversal to download arbitrary system files.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

# Understanding JavaScript Closures Through Call Stack, Heap Memory & `[[Scopes]]`

Closures aren't magic—they're simply JavaScript's way of keeping data alive when a function still needs it. Every JavaScript developer has heard statements l…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 4 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung

Closures aren't magic—they're simply JavaScript's way of keeping data alive when a function still needs it.




Every JavaScript developer has heard statements like:




  • "A closure is a function that remembers variables from its outer scope."

  • "The inner function closes over variables."

  • "Closures preserve the lexical environment."



But...




  • How does a function actually remember variables?

  • Where are those variables stored after the outer function finishes?

  • Why doesn't JavaScript delete them?



Let's go beyond the textbook definition and see what actually happens inside the JavaScript engine.









The Two Main Players Inside the JavaScript Engine



Whenever a function executes, two important memory areas are involved:




  • Call Stack

  • Heap Memory



Understanding closures is really about understanding where JavaScript stores variables and why some of them survive after a function finishes executing.









1. What Happens in a Normal Function?



Consider a simple function:




function greet() {
let name = "JavaScript";
console.log(name);
}

greet();






When greet() executes:




  1. An Execution Context is created.

  2. Local variables (name) belong to that execution.

  3. The execution context is pushed onto the Call Stack.




Call Stack

┌─────────────────────────┐
│ Execution Context │
│ name = "JavaScript" │
└─────────────────────────┘






After the function finishes:




  • The execution context is popped off the stack.

  • No code references name anymore.

  • It becomes eligible for Garbage Collection.



Everything is cleaned up.









2. What Changes When a Closure Is Created?



Now look at this example:




function outerFunction() {

let count = 0;

function innerFunction() {
count++;
console.log(count);
}

return innerFunction;
}

const counter = outerFunction();

counter();
counter();
counter();






Output




1
2
3






But wait...



outerFunction() already finished executing.



Its execution context has been removed from the Call Stack.



So why is count still available?



That's where closures come in.









Behind the Scenes



When JavaScript notices that innerFunction uses count, it understands:




"This variable will still be needed after outerFunction() returns."




Instead of letting count disappear with the execution context, the engine keeps it alive.



Three important things happen behind the scenes.









Step A — Captured Variables Are Kept in Heap Memory



The variables that are captured by an inner function are stored inside an internal object called the Lexical Environment (often called the Closure Context).



Conceptually, you can think of it like this:




Heap Memory

Lexical Environment

{
count: 0
}






Unlike the Call Stack, heap memory isn't destroyed when the function returns.



This allows the captured variables to stay alive.




Note: Engines don't literally "move" variables from the stack to the heap. Instead, captured variables are stored in a heap-allocated lexical environment so they can outlive the function call.










Step B — The Secret Link ([[Scopes]])



Every function internally carries a hidden reference called:




[[Scopes]]






This hidden reference points to the lexical environment containing the variables it needs.



Conceptually:




counter
│
▼
[[Scopes]]
│
▼
Lexical Environment
{
count: 0
}






Even after outerFunction() has finished, the returned function still knows exactly where count lives.









Step C — The Scope Chain



Later, when you execute:




counter();






JavaScript performs variable lookup in this order:




  1. Check the function's local scope.

  2. If not found, follow [[Scopes]].

  3. Search the lexical environment.

  4. Continue upward until the variable is found.



This lookup process is called the Scope Chain.









Visualizing the Entire Process






Before outerFunction() Returns






Call Stack

┌────────────────────────────┐
│ outerFunction() │
│ count = 0 │
│ innerFunction() │
└────────────────────────────┘












After Returning






Call Stack

┌──────────────────────┐
│ Global Execution │
└──────────────────────┘


Heap Memory

┌────────────────────────┐
│ Lexical Environment │
│ count = 0 │
└────────────────────────┘

▲
│
[[Scopes]]
│
▼

innerFunction






The execution context is gone.



The variable survives because the returned function still references it.









A Simple Analogy



Imagine:





  • outerFunction() is a hotel room.


  • count is an important document.

  • Before checking out, you place the document in a secure locker (Heap Memory).

  • You hand the locker key ([[Scopes]]) to your child (innerFunction).



Even after the hotel room is empty, your child still has the key and can access the document whenever needed.



That's exactly how closures work.









Why Are Closures Useful?






1. Data Privacy



Closures let you create private variables.




function createCounter() {

let count = 0;

return {
increment() {
count++;
},

getCount() {
return count;
}
};
}






Nobody outside can directly modify count.









2. Maintaining State



Closures allow functions to remember information between calls.




const counter = outerFunction();

counter();
counter();
counter();






The value of count persists without using global variables.









Key Takeaways



✔ A closure is created when an inner function uses variables from its outer scope.



✔ JavaScript keeps those captured variables alive inside a heap-allocated lexical environment.



✔ The returned function stores a hidden reference called [[Scopes]] to that environment.



✔ As long as the function exists, the captured variables cannot be garbage collected.



✔ Variable lookup through these linked environments is called the Scope Chain.









Final Thought



Closures aren't magic.



They're simply the JavaScript engine preserving the variables that are still needed.



Once you understand the relationship between the Call Stack, Heap Memory, Lexical Environment, and the hidden [[Scopes]] reference, closures become one of the most elegant and powerful features of JavaScript.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Dyskusja społeczności i komentarze

🌐 Dołącz do głównego czatu

Rozpocznij dyskusję w strumieniu transmisji Social Chat lub prześlij wyżej wkład ekspercki przez formularz uzupełnień.

Cyber Threat Intelligence i Kryminalistyka

Navigator ATT&CK · Radar IoC i Graf

CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
3 Knoten · 2 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Community Rating & Social Proof
⭐ Ocena czytelników
–
Ø / 5.0
Brak recenzji czytelników
Czy ten artykuł był pomocny?
0
Dodaj swoją ocenę
Ocena szczegółowa (opcjonalnie)
Treść i jakość
Źródło i wiarygodność
Aktualność
Security Briefing Bezpłatnie · Wypisanie 1 kliknięciem

Intelligence Digest - bezpłatnie

Codziennie najważniejsze wiadomości bezpieczeństwa · można pobrać w każdej chwili

Powiązany klaster opowieści i źródła (wektor AI)

6 Cluster
41 źródeł
Best Black Friday MacBook Air deals: biggest discounts on Apple's thin and light laptop range
Latest from TechRadar 45 minut temu
40 kolejnych źródeł
Latest from TechRadar34 minuty temuProton VPN vs ExpressVPN – which secure VPN should you pick this Black Friday? WIRED9 godzin temuThe 108 Best Black Friday Deals Are Now Live: Our Expert Picks for 2026 WIRED41 minut temu20 Best Black Friday Tech Deals (2026) WIRED39 minut temuThe 10 Best Black Friday TV Deals (2026): Save Up to 53% Off Giga.de31 minut temuBlack Friday 2026 bei Back Market: Dyson, Ninja und GoPro jetzt deutlich günstiger Cyber Security News1 godzinę temuBlack Friday or Black Fraud Day? 7 Cyber Traps to Watch Out for Before You Click ‘Buy’ CNET2 dni temuLive: Black Friday Is Here. Shop Our Favorite Deals and Save Up to 60% Apple, Anker, Bose and More WIRED54 minuty temu22 Best Black Friday Deals Under $100 (2026) WIRED52 minuty temuBest Black Friday Phone Deals (2026): iPhone, Pixel, and More The Verge59 minut temuThe absolute best Black Friday deals we’ve found (so far) Giga.de51 minut temuAirPods Pro 3 im Black-Friday-Sturzflug: So günstig waren Apples Top-In-Ears noch nie PC-WELT49 minut temuBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr PC-WELT49 minut temuBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr t3n.de1 godzinę temuKindle, Echo Dot, Fire TV: Diese neuen Amazon-Geräte sind zum Black Friday stark reduziert Macerkopf.de1 godzinę temuAmazon Black Friday Woche: iPad Air, iPhone 18 Cases, AirTag 2, Fire TV Sticks, Echo Dot und mehr appgefahren.de1 godzinę temuJMGO mit Black Friday-Deals: Heimkino-Bundles bis zu 60 Prozent günstiger PC-WELT1 godzinę temuGoogle Pixel 11 jetzt unglaubliche 430 Euro günstiger im Black-Friday-Deal: Tiefstpreis bei Amazon PC-WELT1 godzinę temuNorton 360 Premium-Security an Black Friday nur 19,99 Euro statt 100 Euro Latest from TechRadar1 godzinę temuThe best Black Friday headphone deals: Sony, AirPods and more Latest from TechRadar1 godzinę temuBest Black Friday mini PC deals 2026 live: Save on desktops from Apple, Geekom, GMKtec, Minisforum, and more Golem.de1 godzinę temuAnzeige: Amazon startet mit Glücksrad-Gewinnspiel in den Black Friday Latest from TechRadar1 godzinę temuThese smart and polished backpacks have accompanied me to events all over the world — and they're now 30% for Black Friday PC-WELT1 godzinę temuRiesiger 75 Zoll 4K-QLED-Fernseher fällt bei Amazon auf nur 469 Eur im Black-Friday-Angebot PC-WELT1 godzinę temuBlack Friday: Beliebte Mähroboter von Mammotion jetzt ab 599 Euro Latest from TechRadar1 godzinę temuSave up to around £200 on these top mini PCs for Black Friday — with multiple options and configurations available for your exact needs or preferences Caschys Blog3 godziny temuFlexiSpot Black Friday 2026: Bis zu 40 % Rabatt auf Bestseller bei Amazon Golem.de1 godzinę temuBlack Friday: Verdi mobilisiert bei Amazon in Gera nur wenige PC-WELT1 godzinę temuNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro appgefahren.de1 godzinę temutink.de bietet bis zu 50 Euro Extra-Rabatt auf Black-Friday-Angebote PC-WELT1 godzinę temuNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro Latest from TechRadar2 godziny temuWhich all-in-one Black Friday VPN bundle is really worth it? I compared NordVPN Prime, ExpressVPN Pro, and Proton Unlimited — all under $7 a month — to decide PC-WELT2 godziny temuAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro PC-WELT2 godziny temuAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro t3n.de2 godziny temuZum Black Friday bei Ecoflow den Heimspeicher fürs Frühjahr sichern PC-WELT2 godziny temuBlack Friday ist da! Die besten Technik-Deals bei Amazon am 27.11. GamingOnLinux Latest Articl…2 godziny temuValve update the Discounts & Events page for Black Friday sales Latest from TechRadar2 godziny temuI'm an Audio Editor and these are the only cheap hi-fi and headphone deals I want you to see this Black Friday t3n.de2 godziny temuFritzbox am Black Friday: 9 gute Angebote rund um Router und Repeater PC-WELT2 godziny temuBlack Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr PC-WELT2 godziny temuBlack Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr
17 źródeł
Google will soon share Android developers' addresses publicly
Engadget - Technology News & Expert Reviews 56 minut temu
16 kolejnych źródeł
VulDB Updates1 godzinę temuCVE-2026-95429 | Google Android BrEdrDynamicChannel bredr_dynamic_channel.cc resource consumption VulDB Updates1 godzinę temuCVE-2026-95434 | Google Android LowEnergyScanner low_energy_scanner.cc NotifyPeerFound resource consumption VulDB Updates1 godzinę temuCVE-2026-95441 | Google Android Bluetooth connection.cc OnDisconnectionComplete denial of service VulDB Updates1 godzinę temuCVE-2026-95422 | Google Android periodic_advertising_synchronizer.cc OnSyncEstablished assertion VulDB Updates1 godzinę temuCVE-2026-95423 | Google Android local_service_manager.cc OnWriteCCC null pointer dereference VulDB Updates1 godzinę temuCVE-2026-95447 | Google Android SDP Client client.cc OnRxFrame memory corruption VulDB Updates1 godzinę temuCVE-2026-95421 | Google Android Command Processing bredr_signaling_channel.cc DecodeRxUnit use after free VulDB Updates1 godzinę temuCVE-2026-95435 | Google Android advertising_data.cc FromBytes out-of-bounds VulDB Updates1 godzinę temuCVE-2026-95446 | Google Android credit_based_flow_control_rx_engine.cc ProcessPdu input validation VulDB Updates1 godzinę temuCVE-2026-95420 | Google Android Pairing security_manager.cc OnEncryptionChange privileges management VulDB Updates1 godzinę temuCVE-2026-95419 | Google Android Bluetooth Security Manager security_manager.cc OnPairingRequest unusual condition VulDB Updates1 godzinę temuCVE-2026-95416 | Google Android Link Encryption Key security_manager.cc OnPairingFailed denial of service VulDB Updates1 godzinę temuCVE-2026-95415 | Google Android RemoteCharacteristic remote_characteristic.cc denial of service VulDB Updates1 godzinę temuCVE-2026-95417 | Google Android remote_characteristic.cc ResolvePendingNotifyRequests use after free VulDB Updates1 godzinę temuCVE-2026-95414 | Google Android http_file_request_handler.cc GetFilePath path traversal VulDB Updates1 godzinę temuCVE-2026-95418 | Google Android logical_link.cc LogicalLink::SignalError use after free
Podobne wkłady
🔍 Verwandte News

Auch interessante Nachrichten # Understanding JavaScript Closures Through Call Stack, Heap Memory & `[[Scopes]]`

Thematisch verwandte Begriffe: Understanding, JavaScript, Closures, Through · 6 Treffer

Laden...

Filmy są załadowane...

Laden...

Składki są załadowane...

Laden...

Filmy są załadowane...

Laden...

Składki są załadowane...

Laden...

Filmy są załadowane...

Laden...

Składki są załadowane...

Laden...

Filmy są załadowane...

Laden...

Składki są załadowane...

Laden...

Filmy są załadowane...

Uwagi Komentarze są ładowane..
Rysunek do aktualizacji
Widgets & Topics
Loading widgets…
Nächster Beitrag