fix: conflicting info updated (#43394)
This commit is contained in:
@ -10,7 +10,7 @@ dashedName: prevent-object-mutation
|
|||||||
|
|
||||||
As seen in the previous challenge, `const` declaration alone doesn't really protect your data from mutation. To ensure your data doesn't change, JavaScript provides a function `Object.freeze` to prevent data mutation.
|
As seen in the previous challenge, `const` declaration alone doesn't really protect your data from mutation. To ensure your data doesn't change, JavaScript provides a function `Object.freeze` to prevent data mutation.
|
||||||
|
|
||||||
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.
|
Any attempt at changing the object will be rejected, with an error thrown if the script is running in strict mode.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let obj = {
|
let obj = {
|
||||||
@ -23,7 +23,7 @@ obj.newProp = "Test";
|
|||||||
console.log(obj);
|
console.log(obj);
|
||||||
```
|
```
|
||||||
|
|
||||||
The `obj.review` and `obj.newProp` assignments will result in errors, and the console will display the value `{ name: "FreeCodeCamp", review: "Awesome" }`.
|
The `obj.review` and `obj.newProp` assignments will result in errors, because our editor runs in strict mode by default, and the console will display the value `{ name: "FreeCodeCamp", review: "Awesome" }`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user