Change var to const or let in es6.md

There were some variables being declared using old `var` syntax, seemed weird in the context.
This commit is contained in:
Benjamin Hollway 2017-11-30 14:42:23 +01:00 committed by GitHub
parent 7451b686ce
commit 5fdc5d5678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

14
es6.md
View File

@ -37,13 +37,13 @@ See: [Let and const](http://babeljs.io/learn-es2015/#ecmascript-2015-features-le
#### Interpolation #### Interpolation
```js ```js
var message = `Hello ${name}` const message = `Hello ${name}`
``` ```
#### Multiline strings #### Multiline strings
```js ```js
var str = ` const str = `
hello hello
world world
` `
@ -186,7 +186,7 @@ Destructuring
#### Arrays #### Arrays
```js ```js
var [first, last] = ['Nikola', 'Tesla'] const [first, last] = ['Nikola', 'Tesla']
``` ```
{: data-line="1"} {: data-line="1"}
@ -206,8 +206,8 @@ See: [Destructuring](http://babeljs.io/learn-es2015/#ecmascript-2015-features-de
### Default values ### Default values
```js ```js
var scores = [22, 33] const scores = [22, 33]
var [math = 50, sci = 50, arts = 50] = scores const [math = 50, sci = 50, arts = 50] = scores
``` ```
```js ```js
@ -491,13 +491,13 @@ Generators
```js ```js
function* idMaker () { function* idMaker () {
var id = 0 let id = 0
while (true) { yield id++ } while (true) { yield id++ }
} }
``` ```
```js ```js
var gen = idMaker() let gen = idMaker()
gen.next().value // → 0 gen.next().value // → 0
gen.next().value // → 1 gen.next().value // → 1
gen.next().value // → 2 gen.next().value // → 2