return {... Output of the above code: In order to see the variable and function bound within closure we can write as: Javascript. This helps us to use the private variables in javascript. Closures in JavaScript Explained with Examples Private variables and methods. There’retwo key elements to be noted in those examples: function and Following is the code for closures in JavaScript − Example: JavaScript Closure Example