I have a question about JavaScript hidden or invisible variables to us. Because they are not created in global context. When we write large web applications, some variables or functions live indivisibly, but we don't know their existence. They eat our resources as CPU, GPU. For example, I always expect that all variables in anonymous function will be removed after it's execution (of course if there is no reference to it from upper context). In this example, I cannot see interval
variable nowhere, but it always writes to console interval
id.
(function () {
var interval = setInterval(function(){
console.log(interval.toLocaleString());
// some heavy operation
}, 1000);
})();
Another example is I've created view in Backbone.js, then I realized that after removing view, it was also exist. My question is, how can I find or see all variables which is exist, but not visible in global context?