When do javascript closures get cleared from memory -


let's have application(in it's rudementary form)

+function($) {    var appname = "foobarbaz";    var appid = appname.replace(/[^a-z]+/gi, '').replace(/(.)([a-z])/g, "$1-$2").tolowercase()    var application = function($elem) {       this.$el = $elem;       this.appname = appname;       this.appid = appid;    }    application.prototype.getid = function() {       return this.appid;    }    application.prototype.setid = function(newid) {      this.appid = newid;    }    $.fn.appthing = function () {        var $this = $(this);       var app = $this.data('app.'+appname);       if(!app) {            $this.data(oc, (data = new application(this)));       }    }  }(window.jquery);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

now if reload happens , $.fn.appthing gets overwritten new(exact same code, freshly loaded) application function , dom elements linked replaced new fresh html content, closure removed memory? or retain somehow.

i'm curious general memory management logic behind javascript standard, , when closure objects released memory, conditions release, memory won't fill on long haul of program running.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo