How to completely restrict the modification of properties of a const object
javascript
Solution
Okay - so it is required to use Object.freeze call t make the object unchangeable. Even the strict mode isn't required.
const x = {a:"sss"}
Object.freeze(x);
x.a = "k"
console.log(x)
Outputs:
x.a = "k"
^
TypeError: Cannot assign to read only property 'a' of object '#<Object>'
Problem
Even after using strict mode, I am able to update the object variable. How is possible? Is it possible to create constant objects at all? ``` "use strict"; const x = {a:"sss"} x.a = "k" console.log(x) ``` outputs: ``` { a: 'k' } ```