₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,027 members, 8,448,263 topics. Date: Monday, 20 July 2026 at 06:12 AM

Toggle theme

Understanding Closures In Javascript - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingUnderstanding Closures In Javascript (836 Views)

1 Reply

Understanding Closures In Javascript by skptricks(op): 1:32pm On Jan 10, 2019
Source : Understanding closures in JavaScript

[img]https://2.bp..com/-CSfsC2igXTw/XB34fvCZXsI/AAAAAAAACRc/kVlEM5pojJcoTFEUgCPAQ-UGfJFefnmoQCLcBGAs/s640/closure.png[/img]

What is a closure?
A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function’s variables — a scope chain.
The closure has three scope chains:
it has access to its own scope — variables defined between its curly brackets
it has access to the outer function’s variables
it has access to the global variables

When to use Closure?
Closure is useful in hiding implementation detail in JavaScript. In other words, it can be useful to create private variables or functions.
1 Reply

Understand Javascript ClosuresHow To Retrieve Data From An Api Using Fetch Api In JavascriptHow Do I Convert Object To Arrey In Javascript234

Hp Elitebook 6930p For SaleI. T Scholarship For All Nigerian UndergraduatePhp Genius