mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
doc: split example into two
This makes sure the "good" and "bad" examples are split into two. Otherwise it'll result in an parse error. PR-URL: https://github.com/nodejs/node/pull/27670 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
This commit is contained in:
@@ -218,15 +218,11 @@ or be removed in the future.
|
||||
|
||||
To avoid these cases, any builtin function overrides should be defined upfront:
|
||||
|
||||
<!-- eslint-disable no-redeclare -->
|
||||
```js
|
||||
const o = {};
|
||||
// THROWS: Cannot assign read only property 'toString' of object
|
||||
o.toString = () => 'string';
|
||||
|
||||
// OK
|
||||
const o = { toString: () => 'string' };
|
||||
|
||||
class X {
|
||||
constructor() {
|
||||
this.toString = () => 'string';
|
||||
@@ -234,6 +230,11 @@ class X {
|
||||
}
|
||||
// THROWS: Cannot assign read only property 'toString' of object
|
||||
new X();
|
||||
```
|
||||
|
||||
```js
|
||||
// OK
|
||||
const o = { toString: () => 'string' };
|
||||
|
||||
class X {
|
||||
toString = undefined;
|
||||
|
||||
Reference in New Issue
Block a user