The function is a first-class citizen in javascript.

When we execute the function then two things will happen.

  1. It will be pushed to the call stack.
  2. and create a new execution context to run that function.

In the execution context, we got following

  1. This — Object this
  2. Args — Argument array we got in functions
  3. Variable environment — Where function variables are stored and after the function execution completes, it will be popped from the call stack and those variables will be available for the garbage collector.

function create() {
cont bigData = new Array(7000);
return function(index){
return bigData[index];

Yash Jawade

JavaScript Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store