Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1306 How can I hold a reference to the current object instance?

You are here: irt.org | FAQ | JavaScript | Object | Q1306 [ previous next ]

If you need to hold lots of references all at once, and don't want a subsequent reference to be overwritten by another then try something like:

<script language="JavaScript"><!--
// define the myString object
function myString(value) {
    this.value = value;

    var now = (new Date()).getTime();
    eval('tmp' + now + ' = this');
    setTimeout('alert(tmp' + now + '.value)',1000);
}

// create an instance of a myString object
var mytext1 = new myString('this is a test');
var mytext2 = new myString('this is another test');
//--></script>

©2018 Martin Webb