[thelist] Javascript object / prototype question

John Lauck recaffeinated at gmail.com
Thu Jan 10 09:57:26 CST 2008


In the example below does this cause a memory problem on line 12.  It's
necessary to save the current object if you are using a lot of functional
js, but does the local variable myobj get destroyed after the call to
do_something()?  My page seems to be running terribly slow but I can't tell
if it's related to the external libs/plugins I'm using or my code.

     1    <script>
     2    function SomeApp(key) {
     3        this.key = key;
     4
     5        this.globals = {
     6          // set a bunch of globals
     7        };
     8    }
     9
    10    SomeApp.prototype = {
    11        do_something: function() {
    12            var myobj = this;
    13            // do something with myobj
    14        }
    15    }
    16
    17
    18    var AppInst = new SomeApp("keystring");
    19    AppInst.do_something();
    20    </script>

Thanks,

John



More information about the thelist mailing list