SlideShare a Scribd company logo
JavaScript Closures
The Story of the Lost Credit Card

A closure is formed when an inner function gets its hands on
free variables (by reference that is).

http://tech.pro/tutorial/1744/javascript-closures-or-the-story-of-the-lost-credit-card
The Happening
function carelessCitizen() {
var card = 3000;
function thievingPunk() {
card = card - 1500;
}
thievingPunk();
}
carelessCitizen();
Set up the CCTV
•
•
•
•
•
•
•

Fire up Google Chrome
Press F12
Go to Sources, Snippets
Right click, choose New
Name it card.js
Write debugger;
Add the rest of the code
Caught in The Act
Frame 1

Press F11
Caught in The Act
Frame 5

TED !!!
BUS
Dumitru Ungureanu
itmitica@gmail.com

More Related Content

DOCX
Calculadora
PPT
Wow! closure in_javascript
PPT
Ambient Media Worldwide Ltd Jd Lr
PPTX
javascript function & closure
PPTX
JavaScript closures
PDF
Callback Function
PPTX
Closure
PDF
Asynchronous JavaScript and Promises
Calculadora
Wow! closure in_javascript
Ambient Media Worldwide Ltd Jd Lr
javascript function & closure
JavaScript closures
Callback Function
Closure
Asynchronous JavaScript and Promises

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Presentation on HIE in infants and its manifestations
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Structure & Organelles in detailed.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
01-Introduction-to-Information-Management.pdf
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
Presentation on HIE in infants and its manifestations
Anesthesia in Laparoscopic Surgery in India
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
GDM (1) (1).pptx small presentation for students
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Computing-Curriculum for Schools in Ghana
Cell Structure & Organelles in detailed.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial disease of the cardiovascular and lymphatic systems
202450812 BayCHI UCSC-SV 20250812 v17.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
01-Introduction-to-Information-Management.pdf
Ad
Ad

JavaScript closures