michael@0: function testClosures() michael@0: { michael@0: function MyObject(id) { michael@0: var thisObject = this; michael@0: this.id = id; michael@0: this.toString = str; michael@0: michael@0: function str() { michael@0: return "" + this.id + thisObject.id; michael@0: } michael@0: } michael@0: michael@0: var a = []; michael@0: for (var i = 0; i < 5; i++) michael@0: a.push(new MyObject(i)); michael@0: return a.toString(); michael@0: } michael@0: assertEq(testClosures(), "00,11,22,33,44");