Added private property #counter to allow internal edits with Object.freez()
For data properties of a frozen object, their values cannot be changed since the writable and configurable attributes are set to false.
If we try to use the increment() or decrement() methods with Object.freez(), we get a TypeError says : Cannot assign to read only property 'counter' of object '#<Counter>' at Counter.increment"
Private properties do not have the concept of property descriptors. Freezing an object with private properties does not prevent the values of these private properties from being changed.
In my request, I've added the #counter property as private property. Now we can use the increment() and decrement() methods with Object.freez() with no errors.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| fm-workshop-2 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jul 7, 2024 9:49am |