By ‘reference’ and by ‘value’

Last Updated on January 2, 2016

By Reference: with Objects (incl. functions)

var a, b;
var a = { myObj: "value" };
b = a;
// b points to same location in memory
console.log(a); // Output: Object {myObj: "value"}
console.log(b); // Output: Object {myObj: "value"}
// EXCEPT when you create a new object with equals operator
var a = { myObj: "value2" };
console.log(a); // Output: Object {myObj: "value2"}

By Value: with primitive types

var a = true;
var b;
var b = a;
//b is now a COPY of a - a new value so 
console.log(a === b); // <- true