@@ -78,15 +78,15 @@ The default evaluator supports direct evaluation of JavaScript expressions:
78
78
``` js
79
79
> 1 + 1
80
80
2
81
- > var m = 2
81
+ > const m = 2
82
82
undefined
83
83
> m + 1
84
84
3
85
85
```
86
86
87
- Unless otherwise scoped within blocks (e.g. ` { ... } ` ) or functions, variables
88
- declared either implicitly or using the ` var ` keyword are declared at the
89
- ` global ` scope.
87
+ Unless otherwise scoped within blocks or functions, variables declared
88
+ either implicitly, or using the ` const ` , ` let ` , or ` var ` keywords
89
+ are declared at the global scope.
90
90
91
91
#### Global and Local Scope
92
92
@@ -96,7 +96,7 @@ it to the `context` object associated with each `REPLServer`. For example:
96
96
97
97
``` js
98
98
const repl = require (' repl' );
99
- var msg = ' message' ;
99
+ const msg = ' message' ;
100
100
101
101
repl .start (' > ' ).context .m = msg;
102
102
```
@@ -115,7 +115,7 @@ To specify read-only globals, context properties must be defined using
115
115
116
116
``` js
117
117
const repl = require (' repl' );
118
- var msg = ' message' ;
118
+ const msg = ' message' ;
119
119
120
120
const r = repl .start (' > ' );
121
121
Object .defineProperty (r .context , ' m' , {
@@ -183,7 +183,7 @@ to the provided callback function:
183
183
184
184
``` js
185
185
function eval (cmd , context , filename , callback ) {
186
- var result;
186
+ let result;
187
187
try {
188
188
result = vm .runInThisContext (cmd);
189
189
} catch (e) {
@@ -275,7 +275,7 @@ function initializeContext(context) {
275
275
context .m = ' test' ;
276
276
}
277
277
278
- var r = repl .start ({prompt: ' >' });
278
+ const r = repl .start ({prompt: ' >' });
279
279
initializeContext (r .context );
280
280
281
281
r .on (' reset' , initializeContext);
@@ -321,7 +321,7 @@ The following example shows two new commands added to the REPL instance:
321
321
``` js
322
322
const repl = require (' repl' );
323
323
324
- var replServer = repl .start ({prompt: ' > ' });
324
+ const replServer = repl .start ({prompt: ' > ' });
325
325
replServer .defineCommand (' sayhello' , {
326
326
help: ' Say hello' ,
327
327
action : function (name ) {
@@ -421,7 +421,7 @@ without passing any arguments (or by passing the `-i` argument):
421
421
422
422
``` js
423
423
$ node
424
- > a = [1 , 2 , 3 ];
424
+ > const a = [1 , 2 , 3 ];
425
425
[ 1 , 2 , 3 ]
426
426
> a .forEach ((v ) => {
427
427
... console .log (v);
@@ -493,7 +493,7 @@ socket, and a TCP socket:
493
493
``` js
494
494
const net = require (' net' );
495
495
const repl = require (' repl' );
496
- var connections = 0 ;
496
+ let connections = 0 ;
497
497
498
498
repl .start ({
499
499
prompt: ' Node.js via stdin> ' ,
0 commit comments