JS

JAVASCRIPT NESTED FUNCTIONS

WHAT & WHY - NESTED FUNCTIONS

A nested function is simply "a function defined inside another function".

This will restrict the scope of the nested function - It will only exist inside the "parent function".

Key point - Less confusion.

A SIMPLE EXAMPLE

DUMMY FUNCTION function demo () {   NESTED FUNCTION   function demoNest () {     console.log("Nested");   }     PROCESS   console.log("Demo");   demoNest(); } CALL DUMMY FUNCTION demo(); // Demo + Nested NESTED FUNCTION GOES POOF demoNest(); // Error