I've been recently learning some javascript in action and get a little bit struck with not quite surely a performance problem which I think is connected to arrays. I wrote a short test function just to test if arrays are passed by reference. And they are. My only quiestion is:
How exactly is it passed?
There are no pointers in javascript, right?
Here are the test functions:
function arr_test(arr) {
for (var i = 0; i < arr.length; i++) {
arr[i] = 50;
}
}
function num_test(num) {
num = 50;
}
var array = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
arr_test(array);
console.log(array);
var num = 10;
num_test(num);
console.log(num);
The output is as expected:
Array [ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 ]
10