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

Q568 Can arrays/objects be nested?

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

Here is an example of nesting arrays/objects:

<script language="JavaScript"><!--
function myObject(number,string,object) {
    this.number = number;
    this.string = string;
    this.object = object;
}

var object1 = new myObject(4,'text',null);
var object2 = new myObject(3,'a b c',object1);
var object3 = new myObject(1,1998,(1,'xyx',object2));

alert(object3.string);               // 1998
alert(object3.object.string);        // a b c
alert(object3.object.object.string); // text
alert(object3.object.object.object); // null
//--></script>

©2018 Martin Webb