Update article.md

This commit is contained in:
Mau Di Bert 2019-06-27 09:39:00 -03:00 committed by GitHub
parent e0def22946
commit a9622d8b00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.