|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * Multiple Variables should Referring to a Single Object |
|
6 * |
|
7 * @path ch08/8.7/S8.7_A1.js |
|
8 * @description Create object and refers to the other object, modify a property in the original object. |
|
9 * We now see that that change is represented in both variables |
|
10 */ |
|
11 |
|
12 ////////////////////////////////////////////////////////////////////////////// |
|
13 //CHECK# |
|
14 // Set obj to an empty object |
|
15 // |
|
16 var obj = new Object(); |
|
17 // objRef now refers to the other object |
|
18 // |
|
19 var objRef = obj; |
|
20 // Modify a property in the original object |
|
21 objRef.oneProperty = -1; |
|
22 obj.oneProperty = true; |
|
23 // We now see that that change is represented in both variables |
|
24 // (Since they both refer to the same object) |
|
25 if(objRef.oneProperty !== true){ |
|
26 $ERROR('#1: var obj = new Object(); var objRef = obj; objRef.oneProperty = -1; obj.oneProperty = true; objRef.oneProperty === true. Actual: ' + (objRef.oneProperty)); |
|
27 }; |
|
28 // |
|
29 ////////////////////////////////////////////////////////////////////////////// |
|
30 |