closure, inner function remembers the variable which is in it's birth scope
here the inner function which is returned remembres the variable that was initialised in the function global scope that is the create counter function.\n\n# Cod
here the inner function which is returned remembres the variable that was initialised in the function global scope that is the create counter function.\n\n# Code\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n    let temp = n-1;\n    return function() {\n       \n       return ++temp; \n    };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
['JavaScript']