summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/ch08/8.7/S8.7_A3.js
blob: b7266bee7311b398ea521003373dc9687ef714e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * Changing the Reference of an Object While Maintaining Integrity
 *
 * @path ch08/8.7/S8.7_A3.js
 * @description Create a reference to the array, and redefine original array with new array
 */

//////////////////////////////////////////////////////////////////////////////
//CHECK#
// Set items to an array (object) of strings
var items = new Array( "one", "two", "three" );
// Set itemsRef to a reference to items
//
var itemsRef = items;
// Set items to equal a new object
//
items = new Array( "new", "array" );
// items and itemsRef now point to different objects.
// items points to new Array( "new", "array" )
// itemsRef points to new Array( "one", "two", "three" )
if( items == itemsRef ){
  $ERROR('#1: var items = new Array( "one", "two", "three" ); var itemsRef = items; items = new Array( "new", "array" ); items != itemsRef');
};
//
//////////////////////////////////////////////////////////////////////////////