-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrowFunctions.js
More file actions
32 lines (27 loc) · 1.05 KB
/
Copy pathArrowFunctions.js
File metadata and controls
32 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
//------------------------------------------------------------------------------
// Expression Bodies
// More expressive closure syntax.
// http://es6-features.org/#ExpressionBodies
//------------------------------------------------------------------------------
odds = evens.map(v => v + 1)
pairs = evens.map(v => ({ even: v, odd: v + 1 }))
nums = evens.map((v, i) => v + i)
//------------------------------------------------------------------------------
// Statement Bodies
// More expressive closure syntax.
// http://es6-features.org/#StatementBodies
//------------------------------------------------------------------------------
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v)
})
//------------------------------------------------------------------------------
// Lexical this
// More intuitive handling of current object context.
// http://es6-features.org/#Lexicalthis
//------------------------------------------------------------------------------
this.nums.forEach((v) => {
if (v % 5 === 0)
this.fives.push(v)
})