DEV Community

Discussion on: Const Is A Lie In JavaScript & Mastering Unit Testing

Collapse
 
stereobooster profile image
stereobooster • Edited

There are two separate concepts:

  • Referential transparency guaranties that variable can't be reassigned
  • Immutability guaranties that value can't be changed

You can have immutable values assigned to not referentially transparent variables, for example:

let todo: Readonly<Todo> = { title: "" };
Enter fullscreen mode Exit fullscreen mode