Question · JavaScript and TypeScript course · Module 12: Functional Programming

Object.freeze() vs const

What is the difference between Object.freeze() and const?

Answer options

  • const protects the variable reference, freeze protects values inside the object
  • There is no difference, both prevent all changes
  • freeze works only on arrays, const on everything
  • const freezes the object deeply, freeze only shallowly

You can check the correct answer by solving this task in the CodeWorlds game.