Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: docs/es6_chromium.md

Issue 2595253002: Add => as an allowed feature to ES6 style guide (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs/es6_chromium.md
diff --git a/docs/es6_chromium.md b/docs/es6_chromium.md
index e9dc7c89afbeeba40836d0a5f55a6f8b08934df4..946a48a585393dfd2e0bc97d724debf7510cdda0 100644
--- a/docs/es6_chromium.md
+++ b/docs/es6_chromium.md
@@ -110,6 +110,46 @@ and [http://es6-features.org/](http://es6-features.org/)
The following features are allowed in Chromium development.
+## `=>` (Arrow Functions)
+
+Arrow functions provide a concise syntax to create a function, and fix a number
+of difficulties with `this` (e.g. eliminating the need to write `const self =
+this`). Particularly useful for nested functions or callbacks.
+
+Prefer arrow functions over `.bind(this)`.
+
+Arrow functions have an implicit return when used without a body block.
+
+**Usage Example:**
+
+```js
+// General usage, eliminating need for .bind(this).
+setTimeout(() => {
+ this.doSomething();
+}, 1000); // no need for .bind(this) or const self = this.
+
+// Another example...
+window.addEventListener('scroll', (event) => {
+ this.doSomething(event);
+}); // no need for .bind(this) or const self = this.
+
+// Implicit return: returns the value if expression not inside a body block.
+() => 1 // returns 1.
+() => {1} // returns undefined - body block does not implicitly return.
+() => {return 1;} // returns 1.
+```
+
+**Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions)
+
+**Discussion Notes / Link to Thread:**
+
+**Note**: => does not work in iOS9. Don't use it in code that runs on Chrome for
+iOS. There's a presubmit that should warn you about this.
+
+[Discussion thread](https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/iJrC4PVSfoU)
+
+---
+
## `Promise`
The Promise object is used for asynchronous computations. A Promise represents a
@@ -224,41 +264,6 @@ frobber.isFrobbing = false; // Works.
---
-## `=>` (Arrow Functions)
-
-Arrow functions provide a concise syntax to create a function, and fix a number
-of difficulties with `this` (e.g. eliminating the need to write `const self =
-this`). Particularly useful for nested functions or callbacks.
-
-Prefer arrow functions over `.bind(this)`.
-
-Arrow functions have an implicit return when used without a body block.
-
-**Usage Example:**
-
-```js
-// General usage, eliminating need for .bind(this).
-setTimeout(() => {
- this.doSomething();
-}, 1000); // no need for .bind(this) or const self = this.
-
-// Another example...
-window.addEventListener('scroll', (event) => {
- this.doSomething(event);
-}); // no need for .bind(this) or const self = this.
-
-// Implicit return: returns the value if expression not inside a body block.
-() => 1 // returns 1.
-() => {1} // returns undefined - body block does not implicitly return.
-() => {return 1;} // returns 1.
-```
-
-**Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions)
-
-**Discussion Notes / Link to Thread:**
-
----
-
## Classes
OOP-style and boilerplate-free class syntax, including inheritance, `super()`,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698