Skip navigation

Tag Archives: reference

JavaScript reference variable references only the final referred object, not a reference itself. When reading this first time, I got confused little.

Consider the JavaScript code below

// declare a variable
var aNames;
// create array and assign reference to aNames
aNames = Array("vkanakaraj", "rajakvk", "javascript");
// declare another variable and reference it to aNames
refNames = aNames;
// check its working
// now assign another array to aNames
aNames = Array(22,25,10);
// still points to vkanakaraj

got it?