2/ Proof #2 — Early Errors
Strict mode is only inside the function — yet nothing prints at all. Not even "Howdy."
JS caught the duplicate parameter error before a single line ran. 🤯
#YDKJS #365DaysOfYDKJS #JavaScript
1
1
34
1/ Proof #1 — Syntax Errors
The console.log never runs — even though it appears before the error.
If JS executed line by line, it would have logged first. It didn't. Parsing happened before execution. 🧠
#YDKJS #365DaysOfYDKJS #JavaScript
1
2
39
6/ Closures are critical in async programming too:
getSomeData finishes almost immediately — but onResponse closes over url and it's always available whenever the ajax call completes. ⚡
#YDKJS #365DaysOfYDKJS #JavaScript
1
2
69
5/ Each closure instance is independent:
incBy1 and incBy3 each have their own closed-over count and step. They don't share state. 🔒
#YDKJS #365DaysOfYDKJS #JavaScript
1
1
19
4/ Closures don't just take a snapshot of a value.
They maintain a live reference to it — meaning if the value changes, the closure always has the most updated version:
#YDKJS #365DaysOfYDKJS #JavaScript
1
1
17
3/ Here's a basic example:
who closes over msg — remembering it every time it's called. ✅
#YDKJS #365DaysOfYDKJS #JavaScript
1
1
12
Before ES6, JavaScript developers were already building modules manually.
Just a function. Returning an object. Hiding data in closure scope.
Simple pattern. Powerful results. 💡
#JavaScript #YDKJS #365DaysOfYDKJS
4
122
3. Now a Book class that extends it:
super() calls the parent constructor. super.print() calls the parent method. ✅#YDKJS #365DaysOfYDKJS #JavaScript
1
1
56
2. Here's a practical example:
A base class with shared data and behaviour. 📌
#YDKJS #365DaysOfYDKJS #JavaScript
1
1
92














