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:
Ruben Bridgewater
2019-05-20 15:48:42 +02:00
parent fddc2d7a7e
commit 6a5376bb94

View File

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