As my understand, Javascript pass object by reference, and a array also a object but when I create a array of integer then passing it to a function as below code:
function testFunc(outTestArray) {
var aiTemp = [1,2,3,4];
/*Using slice(0) to clone array */
outTestArray = aiTemp.slice(0);
}
var aiTest = Array.apply(null, Array(4)).map(Number.prototype.valueOf, 0);
testFunc(aiTest);
console.log(aiTest.toString()); // aiTest still [0,0,0,0]
I also know that the slice(0) function just return a shallow copy of array, but in case the array is only a array of integer. So my question is why the data of aiTest is not modified?