Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: var => let / const in repl.md
  • Loading branch information
vsemozhetbyt committed Dec 12, 2016
commit 61f4eab7315d71be068b2ca0ccf6d69356acc47c
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The , here doesn’t seem quite right to me?

Copy link
Copy Markdown
Contributor Author

@vsemozhetbyt vsemozhetbyt Dec 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax Do you mean "let, or var"? It is a @lance's sentence. It seems he uses Oxford comma here. Should I change it to "let or var"?

Or do you mean another comma?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. I mean the one after implicitly… the Oxford comma after let seems okay here :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended with the last commit. Thank you :)

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 @@ -430,7 +430,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 @@ -502,7 +502,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