Home

Awesome

JavaScript functions & scope explained

Preparing for the journey

1 First class functions

1.1 Assign function to a variable

1.2 Passing function as argument to other function

1.3 Returning function as a value from other function

2 Scoping

Rule 1: Variable declaration hoisting rule

Rule 2: Variable assignment hoisting rule

Rule 3: Function declaration statement hoisting rule

Rule 4: Function definition expression hoisting rule

3 Invocation context(=this)

3.1 Function invocation

3.2 Method invocation

3.3 Constructor invocation

3.3.1 Using prototype object

3.4 Indirect invocation

3.4.1 Call method

3.4.2 Apply method

3.4.3 Testing enumerability

3.4.4 call method - search binary numbers

3.4.5 call method - Internals

3.5 this & nested function issue

3.5.1 Basic reducer function

3.5.2 Simulate problem - reducer factor & this

3.5.3 Using this keyword inside nested function

Further reading