Skip to content

Commit

Permalink
doc: split example into two
Browse files Browse the repository at this point in the history
This makes sure the "good" and "bad" examples are split into two.
Otherwise it'll result in an parse error.

PR-URL: nodejs#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>
  • Loading branch information
BridgeAR committed Jun 11, 2019
1 parent fddc2d7 commit 6a5376b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,23 @@ 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';
}
}
// THROWS: Cannot assign read only property 'toString' of object
new X();
```

```js
// OK
const o = { toString: () => 'string' };

class X {
toString = undefined;
Expand Down

0 comments on commit 6a5376b

Please sign in to comment.