Browse Source

doc: fix examples in repl.md

* Update an example according to an actual REPL session.
* Replace an arrow function with a common function to hold `this`.

PR-URL: https://github.com/nodejs/node/pull/12684
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Vse Mozhet Byt 8 years ago
parent
commit
8092fb0a59
  1. 4
      doc/api/repl.md

4
doc/api/repl.md

@ -341,7 +341,7 @@ replServer.defineCommand('sayhello', {
this.displayPrompt(); this.displayPrompt();
} }
}); });
replServer.defineCommand('saybye', () => { replServer.defineCommand('saybye', function saybye() {
console.log('Goodbye!'); console.log('Goodbye!');
this.close(); this.close();
}); });
@ -448,6 +448,8 @@ without passing any arguments (or by passing the `-i` argument):
```js ```js
$ node $ node
> const a = [1, 2, 3]; > const a = [1, 2, 3];
undefined
> a
[ 1, 2, 3 ] [ 1, 2, 3 ]
> a.forEach((v) => { > a.forEach((v) => {
... console.log(v); ... console.log(v);

Loading…
Cancel
Save