Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reference to javascript array

var ar = ['one', 'two', 'three'];
var ar2 = ar; // assign ar to ar2

ar2[1] = 2; // modify element in ar2

// change to ar2 also changes ar
console.log( ar ); // ["one", 2, "three"]
console.log( ar2 ); // ["one", 2, "three"]

alert( ar === ar2 ); // true (ar and ar2 refer to the same object)
Source by www.dyn-web.com #
 
PREVIOUS NEXT
Tagged: #reference #javascript #array
ADD COMMENT
Topic
Name
3+4 =