Skip to content

Commit 692a369

Browse files
committed
Update "Property flags and descriptors" article
1 parent 73459e6 commit 692a369

File tree

1 file changed

+5
-6
lines changed
  • 1-js/07-object-properties/01-property-descriptors

1 file changed

+5
-6
lines changed

1-js/07-object-properties/01-property-descriptors/article.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Object.defineProperty(obj, propertyName, descriptor)
6363
```
6464

6565
`obj`, `propertyName`
66-
: The object and property to work on.
66+
: The object and its property to apply the descriptor.
6767

6868
`descriptor`
6969
: Property descriptor object to apply.
@@ -116,14 +116,14 @@ Object.defineProperty(user, "name", {
116116
});
117117

118118
*!*
119-
user.name = "Pete"; // Error: Cannot assign to read only property 'name'...
119+
user.name = "Pete"; // Error: Cannot assign to read only property 'name'
120120
*/!*
121121
```
122122

123123
Now no one can change the name of our user, unless they apply their own `defineProperty` to override ours.
124124

125125
```smart header="Errors appear only in strict mode"
126-
In the non-strict mode, no errors occur when writing to non-writable properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
126+
In non-strict mode, no errors occur when writing to non-writable properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
127127
```
128128

129129
Here's the same example, but the property is created from scratch:
@@ -140,11 +140,10 @@ Object.defineProperty(user, "name", {
140140
*/!*
141141
});
142142

143-
alert(user.name); // Pete
144-
user.name = "Alice"; // Error
143+
alert(user.name); // John
144+
user.name = "Pete"; // Error
145145
```
146146

147-
148147
## Non-enumerable
149148

150149
Now let's add a custom `toString` to `user`.

0 commit comments

Comments
 (0)