Skip to content

Commit

Permalink
doc: var => let / const in repl.md
Browse files Browse the repository at this point in the history
PR-URL: #10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
vsemozhetbyt authored and evanlucas committed Jan 4, 2017
1 parent 6f8c613 commit 37cb971
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ The default evaluator supports direct evaluation of JavaScript expressions:
```js
> 1 + 1
2
> var m = 2
> const m = 2
undefined
> m + 1
3
```

Unless otherwise scoped within blocks (e.g. `{ ... }`) or functions, variables
declared either implicitly or using the `var` keyword are declared at the
`global` scope.
Unless otherwise scoped within blocks or functions, variables declared
either implicitly, or using the `const`, `let`, or `var` keywords
are declared at the global scope.

#### Global and Local Scope

Expand All @@ -96,7 +96,7 @@ it to the `context` object associated with each `REPLServer`. For example:

```js
const repl = require('repl');
var msg = 'message';
const msg = 'message';

repl.start('> ').context.m = msg;
```
Expand All @@ -115,7 +115,7 @@ To specify read-only globals, context properties must be defined using

```js
const repl = require('repl');
var msg = 'message';
const msg = 'message';

const r = repl.start('> ');
Object.defineProperty(r.context, 'm', {
Expand Down Expand Up @@ -183,7 +183,7 @@ to the provided callback function:

```js
function eval(cmd, context, filename, callback) {
var result;
let result;
try {
result = vm.runInThisContext(cmd);
} catch (e) {
Expand Down Expand Up @@ -275,7 +275,7 @@ function initializeContext(context) {
context.m = 'test';
}

var r = repl.start({prompt: '>'});
const r = repl.start({prompt: '>'});
initializeContext(r.context);

r.on('reset', initializeContext);
Expand Down Expand Up @@ -321,7 +321,7 @@ The following example shows two new commands added to the REPL instance:
```js
const repl = require('repl');

var replServer = repl.start({prompt: '> '});
const replServer = repl.start({prompt: '> '});
replServer.defineCommand('sayhello', {
help: 'Say hello',
action: function(name) {
Expand Down Expand Up @@ -421,7 +421,7 @@ without passing any arguments (or by passing the `-i` argument):

```js
$ node
> a = [1, 2, 3];
> const a = [1, 2, 3];
[ 1, 2, 3 ]
> a.forEach((v) => {
... console.log(v);
Expand Down Expand Up @@ -493,7 +493,7 @@ socket, and a TCP socket:
```js
const net = require('net');
const repl = require('repl');
var connections = 0;
let connections = 0;

repl.start({
prompt: 'Node.js via stdin> ',
Expand Down

0 comments on commit 37cb971

Please sign in to comment.