Merge pull request #303 from nothingrandom/patch-1
Change var to const or let in es6.md
This commit is contained in:
commit
cc97056937
14
es6.md
14
es6.md
|
@ -37,13 +37,13 @@ See: [Let and const](https://babeljs.io/learn-es2015/#let--const)
|
||||||
#### 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](https://babeljs.io/learn-es2015/#destructuring)
|
||||||
### 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
|
||||||
|
|
Loading…
Reference in New Issue