Javascript
Apr 27, 2026
What gets logged?
const obj = { a: 1 }
Object.freeze(obj)
obj.a = 99
console.log(obj.a)
Explanation
Object.freeze() locks an object so its properties cannot be changed. Trying to change obj.a silently does nothing in normal mode. In strict mode it would throw an error. The value stays 1. Freeze is shallow — it only protects the top level, not nested objects.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.