Update article.md
This commit is contained in:
parent
e0def22946
commit
a9622d8b00
1 changed files with 4 additions and 4 deletions
|
@ -122,6 +122,10 @@ user.name = "Pete"; // Error: Cannot assign to read only property 'name'...
|
||||||
|
|
||||||
Now no one can change the name of our user, unless they apply their own `defineProperty` to override ours.
|
Now no one can change the name of our user, unless they apply their own `defineProperty` to override ours.
|
||||||
|
|
||||||
|
```smart header="Errors appear only in use strict"
|
||||||
|
In the non-strict mode, no errors occur when writing to read-only properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
|
||||||
|
```
|
||||||
|
|
||||||
Here's the same operation, but for the case when a property doesn't exist:
|
Here's the same operation, but for the case when a property doesn't exist:
|
||||||
|
|
||||||
```js run
|
```js run
|
||||||
|
@ -239,10 +243,6 @@ Object.defineProperty(user, "name", {writable: true}); // Error
|
||||||
*/!*
|
*/!*
|
||||||
```
|
```
|
||||||
|
|
||||||
```smart header="Errors appear only in use strict"
|
|
||||||
In the non-strict mode, no errors occur when writing to read-only properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Object.defineProperties
|
## Object.defineProperties
|
||||||
|
|
||||||
There's a method [Object.defineProperties(obj, descriptors)](mdn:js/Object/defineProperties) that allows to define many properties at once.
|
There's a method [Object.defineProperties(obj, descriptors)](mdn:js/Object/defineProperties) that allows to define many properties at once.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue