Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 8b7f266

Browse files
committed
Create ES6-Cheat-Sheet.md
1 parent 9d702c9 commit 8b7f266

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

ES6-Cheat-Sheet.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ES6 Syntax
2+
------------
3+
4+
I use ES6 because it gives me easy-to-code classes and because the last line is always returned in arrow functions (which is great for promise chaining). You do not have to use ES6, and should not refactor into it 'just because'.
5+
6+
### How To Read
7+
8+
**Javascript:**
9+
```js
10+
function( x, y, z ){
11+
return z
12+
}
13+
14+
function x(z) {
15+
// constructor
16+
this.y = z;
17+
}
18+
x.prototype.method = function(){}
19+
```
20+
**ES6**
21+
```js
22+
// `this` is bound to OUTER scope
23+
( x, y, z ) => {
24+
this.whatever;
25+
}
26+
// single-line functions without brackets returns their expression
27+
( x ) => x.y
28+
// single-argument signatures don't need parenthesis
29+
response => response.data
30+
31+
32+
33+
class x {
34+
constructor(z) {
35+
this.y = z;
36+
}
37+
method(z) {}
38+
}
39+
```

0 commit comments

Comments
 (0)