openpolitics.com

  • writing
  • quotes
  • Topics
    • academia
    • corruption
    • economics
    • education
    • environment
    • finance
    • history
    • hypertext
    • media
    • philosophy
    • psychology
    • religion
    • russia
    • ted nelson
  • about

ES2015 const is not about immutability

const creates an immutable binding

To make an object’s values immutable, use Object.freeze(). It has been around since ES5 and is widely available nowadays.

const foo = Object.freeze({
	'bar': 27
});
foo.bar = 42; // throws a TypeError exception in strict mode;
              // silently fails in sloppy mode


Source:

Tags: ecmascript, immutable, javascript, programming

Read More

Interesting Links:

  • Beau of the Fifth Column
  • René Girard: 5-part CBC Interview Series

Tim Langeman © 2023 · Genesis Framework · WordPress · Log in

Click to access the login or register cheese