Javascript Understanding Variable Scope and closures

Hi All,

I learned from some Youtube video some of my friends share to me and personal thank to Daniel Zabinskas

First of all thanks to sitepoint

1. Declaring Variables

2. Hiding global Variables with local variables of the same name

3. Scope Chain-I

  • When you have nested functions you can create a scope ‘Chain’
  • The browser travels up this chain when looking for a variables value

4. Scope Chain-II

  • When you have nested functions you can create a scope ‘Chain’
  • The browser travels up this chain when looking for a variables value

5.1 addEventListener in JavaScript

5.2 Clouser in the real world example