Javascript is pass by value for primitives (for objects too - but in that case, the value is a reference to the object). However, when an object is passed into an array, this value is a reference to an object. When you pass an object or array, you are passing a reference to that object, and it is possible to modify the contents of that object, but if you attempt to overwrite the reference it will not affect the copy of the reference held by the caller i.e. the reference itself is passed by value.
When you pass in a primitive (e.g. string/number), the value is passed in by value. Any changes to that variable while in the function are separate from whatever happens outside the function.
Pass by value for primitives
function testFunction(x) {
// x is 4
x = 5;
// x is now 5
}
var x = 4;
alert(x); // x is equal to 4
testFunction(x);
alert(x); // x is still equal to 4
Passing an object is by reference (pass by value but this value is a reference):
function myObject() {
this.value = 5;
}
var o = new myObject();
alert(o.value); // o.value = 5
function objectchanger(fnc) {
fnc.value = 6;
}
objectchanger(o);
alert(o.value); // o.value is now equal to 6
Passing in a method of an object is not passed by reference though (due to the lost context when you pass in a function as a parameter).