rw-book-cover

Metadata

Highlights

  • When we use the let keyword to create a variable, we’re able to change which “thing” that label refers to. (View Highlight)
  • (View Highlight)
  • This is known as re-assignment. We’re saying that actually, the fruits label should refer to an entirely different value: (View Highlight)
  • By contrast, variables created with const cannot be reassigned: (View Highlight)
  • (View Highlight)
  • Here’s the thing, though: we’re still allowed to modify the data itself! As long as the label remains intact. (View Highlight)
  • When we create a constant with const, we can be 100% sure that the variable will never be re-assigned, but no promises are made when it comes to mutation. const doesn’t block mutation at all. (View Highlight)
  • As far as I know, Object.freeze() is bulletproof. There’s no way to modify an object/array that has been frozen using this method. (View Highlight)
  • Here’s the deal: all primitive data types in JavaScript are immutable. It’s impossible to “edit” the value of a number. We can only reassign the variable to a different value. (View Highlight)