Arrays as objects are passed in functions by reference while primitives (e.g. strings and numbers) are passed by value. Here is an example:
function test(arr, obj, prim) {
arr[0]++; // by reference
obj.prop++; // by reference
prim++; // by value
return prim; // to get the amended primitive value back
}
var arr = [0],
obj = { prop: 0 },
prim = 0,
result;
result = test(arr, obj, prim);
console.log(arr, obj, prim); // [1], Object {prop: 1}, 0
console.log(result); // 1
GOOD ARTICLE: http://snook.ca/archives/javascript/javascript_pass