Scoping is undoubtedly the most important aspect of any programming language. Understanding how scope works is absolutely essential when learning JavaScript for the 1st time.
In this tutorial we look at, global scope vs block scope vs functions scope. The differences between them can be quite subtle, which the examples as demonstrated in the video, help to clarify.
As a bonus, we also discuss lexical scoping vs dynamic scoping (AKA static scoping).
00:00 - Global scope is the default
01:05 - Block scope's curly braces
02:50 - Nested if-statements scope
04:25 - If and for-loop nested statements
06:22 - Function scope applies to "var"
07:19 - Lexical scope vs dynamic scope
08:59 - Nested functions are simple
Негізгі бет Learning about JavaScript Scope is Easy - Fun & Essential!
Пікірлер