Skip to content

Instantly share code, notes, and snippets.

View tp-hk's full-sized avatar
🛠️
code for work; code for hobby;

TP | HK tp-hk

🛠️
code for work; code for hobby;
  • Saṃsāra
View GitHub Profile
@tp-hk
tp-hk / immutability-vs-reassignment.js
Created October 17, 2018 21:28 — forked from battmanz/immutability-vs-reassignment.js
Demonstrates the difference between an immutable object and a variable that cannot be reassigned
'use strict';
// CASE 1: The object is mutable and the variable can be reassigned.
let o1 = { foo: 'bar' };
// Mutate the object
o1.foo = 'something different';
// Reassign the variable
o1 = { message: "I'm a completely new object" };