Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,796,435 members, 6,680,578 topics. Date: Tuesday, 18 January 2022 at 12:25 PM

Understanding Closures In Javascript - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Understanding Closures In Javascript (686 Views)

Javascripters: Telegram Group To All Interested In Javascript And Its Ecosystem / How To Retrieve Data From An Api Using Fetch Api In Javascript / How Do I Convert Object To Arrey In Javascript (2) (3) (4)

(1) (Reply)

Understanding Closures In Javascript by skptricks: 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)

How To Get More Traffic And Link Your Website / Google’s Global Coding Competition. / Microsoft Launches All-female Coding Training In Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2022 Oluwaseun Osewa. All rights reserved. See How To Advertise. 22
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.