From 87d321e9ef53e6aca39ce38445235f6c2c2a4dd5 Mon Sep 17 00:00:00 2001 From: tommyZZM Date: Wed, 2 Dec 2015 16:25:29 +0800 Subject: [PATCH 1/4] Update style.md usage of Arrow function --- docs/style.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/style.md b/docs/style.md index 49cc1dd..28c4378 100644 --- a/docs/style.md +++ b/docs/style.md @@ -260,9 +260,14 @@ const nodes = Array.from(foo); }); // good -[1, 2, 3].map((x) => { +[1, 2, 3].map(x => { return x * x; }); + +// with more than one argument +[1, 2, 3].map((x,i) => { + return x * i; +}); ``` 箭头函数取代`Function.prototype.bind`,不应再用self/\_this/that绑定 this。 From 372eb0f67f2b1aec883784772a0b1615fc23e267 Mon Sep 17 00:00:00 2001 From: tommyZZM Date: Wed, 2 Dec 2015 16:29:03 +0800 Subject: [PATCH 2/4] Update style.md --- docs/style.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/style.md b/docs/style.md index 28c4378..6f51794 100644 --- a/docs/style.md +++ b/docs/style.md @@ -260,12 +260,11 @@ const nodes = Array.from(foo); }); // good -[1, 2, 3].map(x => { - return x * x; -}); +[1, 2, 3].map(x => x * x); -// with more than one argument +// with more argument and code [1, 2, 3].map((x,i) => { + console.log(x); return x * i; }); ``` From 421b8ab3210f9de90723bc16e9e59b3a32912320 Mon Sep 17 00:00:00 2001 From: tommyZZM Date: Wed, 2 Dec 2015 16:38:49 +0800 Subject: [PATCH 3/4] Update style.md --- docs/style.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/style.md b/docs/style.md index 6f51794..fcdd7e2 100644 --- a/docs/style.md +++ b/docs/style.md @@ -260,11 +260,15 @@ const nodes = Array.from(foo); }); // good +[1, 2, 3].map((x) => { + return x * x; +}); + +// best [1, 2, 3].map(x => x * x); -// with more argument and code +// best [1, 2, 3].map((x,i) => { - console.log(x); return x * i; }); ``` From 94f0d4921f1a5c76726701fff35eb89310b566bb Mon Sep 17 00:00:00 2001 From: tommyZZM Date: Wed, 2 Dec 2015 16:44:36 +0800 Subject: [PATCH 4/4] Update style.md --- docs/style.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/style.md b/docs/style.md index fcdd7e2..33ac06c 100644 --- a/docs/style.md +++ b/docs/style.md @@ -266,11 +266,6 @@ const nodes = Array.from(foo); // best [1, 2, 3].map(x => x * x); - -// best -[1, 2, 3].map((x,i) => { - return x * i; -}); ``` 箭头函数取代`Function.prototype.bind`,不应再用self/\_this/that绑定 this。