@@ -78,15 +78,15 @@ The default evaluator supports direct evaluation of JavaScript expressions:
7878``` js
7979> 1 + 1
80802
81- > var m = 2
81+ > const m = 2
8282undefined
8383> m + 1
84843
8585```
8686
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.
9090
9191#### Global and Local Scope
9292
@@ -96,7 +96,7 @@ it to the `context` object associated with each `REPLServer`. For example:
9696
9797``` js
9898const repl = require (' repl' );
99- var msg = ' message' ;
99+ const msg = ' message' ;
100100
101101repl .start (' > ' ).context .m = msg;
102102```
@@ -115,7 +115,7 @@ To specify read-only globals, context properties must be defined using
115115
116116``` js
117117const repl = require (' repl' );
118- var msg = ' message' ;
118+ const msg = ' message' ;
119119
120120const r = repl .start (' > ' );
121121Object .defineProperty (r .context , ' m' , {
@@ -183,7 +183,7 @@ to the provided callback function:
183183
184184``` js
185185function eval (cmd , context , filename , callback ) {
186- var result;
186+ let result;
187187 try {
188188 result = vm .runInThisContext (cmd);
189189 } catch (e) {
@@ -275,7 +275,7 @@ function initializeContext(context) {
275275 context .m = ' test' ;
276276}
277277
278- var r = repl .start ({prompt: ' >' });
278+ const r = repl .start ({prompt: ' >' });
279279initializeContext (r .context );
280280
281281r .on (' reset' , initializeContext);
@@ -321,7 +321,7 @@ The following example shows two new commands added to the REPL instance:
321321``` js
322322const repl = require (' repl' );
323323
324- var replServer = repl .start ({prompt: ' > ' });
324+ const replServer = repl .start ({prompt: ' > ' });
325325replServer .defineCommand (' sayhello' , {
326326 help: ' Say hello' ,
327327 action : function (name ) {
@@ -421,7 +421,7 @@ without passing any arguments (or by passing the `-i` argument):
421421
422422``` js
423423$ node
424- > a = [1 , 2 , 3 ];
424+ > const a = [1 , 2 , 3 ];
425425[ 1 , 2 , 3 ]
426426> a .forEach ((v ) => {
427427... console .log (v);
@@ -493,7 +493,7 @@ socket, and a TCP socket:
493493``` js
494494const net = require (' net' );
495495const repl = require (' repl' );
496- var connections = 0 ;
496+ let connections = 0 ;
497497
498498repl .start ({
499499 prompt: ' Node.js via stdin> ' ,
0 commit comments