Skip to content

Commit 052c7d0

Browse files
committed
Fix syntax error with es6 {} blocks
1 parent 377256e commit 052c7d0

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Using ES6 Blocks:
9999
```javascript
100100
{
101101
let food = 'Meow Mix';
102-
}
102+
};
103103

104104
console.log(food); // Reference Error
105105
```
@@ -425,7 +425,7 @@ let api = {
425425

426426
export default api;
427427

428-
/* Which is the same as
428+
/* Which is the same as
429429
* export { api as default };
430430
*/
431431
```
@@ -725,7 +725,7 @@ React.Component.prototype[refreshComponent] = () => {
725725
### Symbol.for(key)
726726

727727
`Symbol.for(key)` will create a Symbol that is still immutable and unique, but can be looked up globally.
728-
Two identical calls to `Symbol.for(key)` will return the same Symbol instance. NOTE: This is not true for
728+
Two identical calls to `Symbol.for(key)` will return the same Symbol instance. NOTE: This is not true for
729729
`Symbol(description)`:
730730

731731
```javascript
@@ -734,8 +734,8 @@ Symbol.for('foo') === Symbol('foo') // false
734734
Symbol.for('foo') === Symbol.for('foo') // true
735735
```
736736

737-
A common use case for Symbols, and in particular with `Symbol.for(key)` is for interoperability. This can be
738-
achieved by having your code look for a Symbol member on object arguments from third parties that contain some
737+
A common use case for Symbols, and in particular with `Symbol.for(key)` is for interoperability. This can be
738+
achieved by having your code look for a Symbol member on object arguments from third parties that contain some
739739
known interface. For example:
740740

741741
```javascript
@@ -764,7 +764,7 @@ class SomeReadableType {
764764
```
765765

766766
> A notable example of Symbol use for interoperability is `Symbol.iterator` which exists on all iterable
767-
types in ES6: Arrays, strings, generators, etc. When called as a method it returns an object with an Iterator
767+
types in ES6: Arrays, strings, generators, etc. When called as a method it returns an object with an Iterator
768768
interface.
769769

770770
<sup>[(back to table of contents)](#table-of-contents)</sup>
@@ -894,7 +894,7 @@ let value = map.get(el); // 'reference'
894894
el.parentNode.removeChild(el);
895895
el = null;
896896

897-
// map is empty, since the element is destroyed
897+
// map is empty, since the element is destroyed
898898
```
899899

900900
As shown above, once the object is destroyed by the garbage collector,
@@ -1005,9 +1005,9 @@ Promise.all(promises)
10051005

10061006
## Generators
10071007

1008-
Similar to how [Promises](https://github.com/DrkSephy/es6-cheatsheet#promises) allow us to avoid
1008+
Similar to how [Promises](https://github.com/DrkSephy/es6-cheatsheet#promises) allow us to avoid
10091009
[callback hell](http://callbackhell.com/), Generators allow us to flatten our code - giving our
1010-
asynchronous code a synchronous feel. Generators are essentially functions which we can
1010+
asynchronous code a synchronous feel. Generators are essentially functions which we can
10111011
[pause their execution](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield)
10121012
and subsequently return the value of an expression.
10131013

@@ -1054,9 +1054,9 @@ function* getData() {
10541054
```
10551055

10561056
By the power of `yield`, we are guaranteed that `entry1` will have the data needed to be parsed and stored
1057-
in `data1`.
1057+
in `data1`.
10581058

1059-
While generators allow us to write asynchronous code in a synchronous manner, there is no clear
1059+
While generators allow us to write asynchronous code in a synchronous manner, there is no clear
10601060
and easy path for error propagation. As such, as we can augment our generator with Promises:
10611061

10621062
```javascript
@@ -1077,12 +1077,12 @@ function iterateGenerator(gen) {
10771077
var ret = generator.next();
10781078
if(!ret.done) {
10791079
ret.value.then(iterate);
1080-
}
1081-
})();
1080+
}
1081+
})();
10821082
}
10831083
```
10841084

1085-
By augmenting our Generator with Promises, we have a clear way of propagating errors through the use of our
1085+
By augmenting our Generator with Promises, we have a clear way of propagating errors through the use of our
10861086
Promise `.catch` and `reject`. To use our newly augmented Generator, it is as simple as before:
10871087

10881088
```javascript
@@ -1103,25 +1103,25 @@ errors in a nice way, we can actually begin to utilize a simpler construction th
11031103

11041104
## Async Await
11051105

1106-
While this is actually an upcoming ES2016 feature, `async await` allows us to perform the same thing we accomplished
1106+
While this is actually an upcoming ES2016 feature, `async await` allows us to perform the same thing we accomplished
11071107
using Generators and Promises with less effort:
11081108

11091109
```javascript
11101110
var request = require('request');
1111-
1111+
11121112
function getJSON(url) {
11131113
return new Promise(function(resolve, reject) {
11141114
request(url, function(error, response, body) {
11151115
resolve(body);
11161116
});
11171117
});
11181118
}
1119-
1119+
11201120
async function main() {
11211121
var data = await getJSON();
11221122
console.log(data); // NOT undefined!
11231123
}
1124-
1124+
11251125
main();
11261126
```
11271127

@@ -1149,7 +1149,7 @@ class Employee {
11491149
}
11501150

11511151
set name(newName) {
1152-
if (newName == this._name) {
1152+
if (newName == this._name) {
11531153
console.log('I already have this name.');
11541154
} else if (newName) {
11551155
this._name = newName;
@@ -1162,12 +1162,12 @@ class Employee {
11621162
var emp = new Employee("James Bond");
11631163

11641164
// uses the get method in the background
1165-
if (emp.name) {
1165+
if (emp.name) {
11661166
console.log(emp.name); // Mr. JAMES BOND
11671167
}
11681168

11691169
// uses the setter in the background
1170-
emp.name = "Bond 007";
1170+
emp.name = "Bond 007";
11711171
console.log(emp.name); // Mr. BOND 007
11721172
```
11731173

README_ko.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ES6 블록을 사용하는 경우,
8888
```javascript
8989
{
9090
let food = '허니버터칩';
91-
}
91+
};
9292

9393
console.log(food); // Reference Error
9494
```

README_zhCn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ console.log(food); // Reference Error
8989
```javascript
9090
{
9191
let food = 'Meow Mix';
92-
}
92+
};
9393

9494
console.log(food); // Reference Error
9595
```

0 commit comments

Comments
 (0)