michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * Passing arguments by reference do change values of reference to be passed michael@0: * michael@0: * @path ch08/8.7/S8.7_A7.js michael@0: * @description Add new property to original variable inside function michael@0: */ michael@0: michael@0: var n = {}; michael@0: var m = n; michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#1 michael@0: if (typeof m !== "object") { michael@0: $ERROR('#1: var n = {}; var m = n; typeof m === "object". Actual: ' + (typeof m)); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: function populateAge(person){person.age = 50;} michael@0: michael@0: populateAge(m); michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#2 michael@0: if (n.age !== 50) { michael@0: $ERROR('#2: var n = {}; var m = n; function populateAge(person){person.age = 50;} populateAge(m); n.age === 50. Actual: ' + (n.age)); michael@0: } michael@0: michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: