Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 530 Bytes

references.md

File metadata and controls

24 lines (17 loc) · 530 Bytes

References

Beyond literals, any Object in JavaScript (including functions, arrays, regexp etc) are references. This means the following

Mutations are across all references

var foo = {};
var bar = foo; // bar is a reference to the same object

foo.baz = 123;
console.log(bar.baz); // 123

Equality is for references

var foo = {};
var bar = foo; // bar is a reference
var baz = {}; // baz is a *new object* distinct from `foo`

console.log(foo === bar); // true
console.log(foo === baz); // false