1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 * File Name: forin-002.js
5 * Description: The forin-001 statement
7 * Verify that the property name is assigned to the property on the left
8 * hand side of the for...in expression.
10 * Author: christine@netscape.com
11 * Date: 28 August 1998
13 var SECTION = "forin-002";
14 var VERSION = "ECMA_2";
15 var TITLE = "The for...in statement";
18 writeHeaderToLog( SECTION + " "+ TITLE);
20 function MyObject( value ) {
22 this.valueOf = new Function ( "return this.value" );
23 this.toString = new Function ( "return this.value + \"\"" );
24 this.toNumber = new Function ( "return this.value + 0" );
25 this.toBoolean = new Function ( "return Boolean( this.value )" );
31 ForIn_1(new MyObject(true));
32 ForIn_2(new MyObject(new Boolean(true)));
39 * For ... In in a With Block
42 function ForIn_1( object) {
44 for ( property in object ) {
47 "with loop in a for...in loop. ("+object+")["+property +"] == "+
48 "eval ( " + property +" )",
50 object[property] == eval(property) );
56 * With block in a For...In loop
59 function ForIn_2(object) {
60 for ( property in object ) {
64 "with loop in a for...in loop. ("+object+")["+property +"] == "+
65 "eval ( " + property +" )",
67 object[property] == eval(property) );