Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Object | Q1306 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.