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>
This commit is contained in:
Vse Mozhet Byt authored and Evan Lucas committed 2017-05-02 20:39:14 -05:00
1 parent 373e9f08af
commit 360efe48bc
1 file changed
+3 -1
+3 -1
View File
@@ -335,7 +335,7 @@ replServer.defineCommand('sayhello', {
this.displayPrompt();
}
});
replServer.defineCommand('saybye', () => {
replServer.defineCommand('saybye', function saybye() {
console.log('Goodbye!');
this.close();
});
@@ -440,6 +440,8 @@ without passing any arguments (or by passing the `-i` argument):
```js
$ node
> const a = [1, 2, 3];
undefined
> a
[ 1, 2, 3 ]
> a.forEach((v) => {
... console.log(v);