Based on this learning material:
Once the object is frozen, you can no longer add, update, or delete properties from it. Any attempt at changing the object will be rejected without an error.
The text says there will be no error shown but I’m still getting error while running the code below.
let obj = {
name:"FreeCodeCamp",
review:"Awesome"
};
Object.freeze(obj);
obj.review = "bad";
obj.newProp = "Test";
console.log(obj);
Here are the error I got:
TypeError: Cannot assign to read only property 'review' of object '#<Object>'
TypeError: Cannot add property newProp, object is not extensible
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.78
Challenge: Prevent Object Mutation
Link to the challenge: