What are JavaScript Function Closures?

JavaScript function closure is the grouping of a function and where that function was declared. In JavaScript, all functions work like closures. A closure is a function uses the scope in which it was declared when invoked. It is not the scope in which it was invoked.

Here’s an example

Live Demo

      <h2>Working with JavaScript Closures</h2>
         var num = 10;
         function a() {
            var num = 15;
            b(function() {
         function b(f) {
            var num = 30;