You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Prototypal inheritance with a simple syntax `class PonyFoo <mark>extends</mark> Foo {}`
165
+
- Prototypal inheritance with a simple syntax `class PonyFoo extends Foo {}`
166
166
- Read [ES6 Classes in Depth][8]
167
167
168
168
<sup>[(back to table of contents)](#table-of-contents)</sup>
@@ -186,7 +186,7 @@ Apologies about that long table of contents, and here we go.
186
186
- Declaration of a variable by the same name will throw
187
187
- Meant to fix mistakes where you reassign a variable and lose a reference that was passed along somewhere else
188
188
- In ES6, **functions are block scoped**
189
-
- Prevents leaking block-scoped secrets through hoisting, `{ <mark>let</mark> _foo = 'secret', bar = <mark>() => _foo</mark>; }`
189
+
- Prevents leaking block-scoped secrets through hoisting, `{ let _foo = 'secret', bar = () => _foo; }`
190
190
- Doesn't break user code in most situations, and typically what you wanted anyways
191
191
- Read [ES6 Let, Const and the “Temporal Dead Zone” (TDZ) in Depth][9]
192
192
@@ -196,7 +196,7 @@ Apologies about that long table of contents, and here we go.
196
196
197
197
- A new primitive type in ES6
198
198
- You can create your own symbols using `var symbol = Symbol()`
199
-
- You can add a description for debugging purposes, like `Symbol(<mark>'ponyfoo'</mark>)`
199
+
- You can add a description for debugging purposes, like `Symbol('ponyfoo')`
200
200
- Symbols are immutable and unique. `Symbol()`, `Symbol()`, `Symbol('foo')` and `Symbol('foo')` are all different
201
201
- Symbols are of type `symbol`, thus: `typeof Symbol() === 'symbol'`
202
202
- You can also create global symbols with `Symbol.for(key)`
@@ -224,7 +224,7 @@ Apologies about that long table of contents, and here we go.
224
224
225
225
- Iterator and iterable protocol define how to iterate over any object, not just arrays and array-likes
226
226
- A well-known `Symbol` is used to assign an iterator to any object
227
-
-`var foo = { [<mark>Symbol.iterator</mark>]: iterable}`, or `foo[<mark>Symbol.iterator</mark>] = iterable`
227
+
-`var foo = { [Symbol.iterator]: iterable}`, or `foo[Symbol.iterator] = iterable`
228
228
- The `iterable` is a method that returns an `iterator` object that has a `next` method
229
229
- The `next` method returns objects with two properties, `value` and `done`
230
230
- The `value` property indicates the current value in the sequence being iterated
@@ -242,7 +242,7 @@ Apologies about that long table of contents, and here we go.
242
242
243
243
# Generators
244
244
245
-
- Generator functions are a special kind of _iterator_ that can be declared using the `<mark>function*</mark> generator () {}` syntax
245
+
- Generator functions are a special kind of _iterator_ that can be declared using the `function* generator () {}` syntax
246
246
- Generator functions use `yield` to emit an element sequence
247
247
- Generator functions can also use `yield*` to delegate to another generator function _-- or any iterable object_
248
248
- Generator functions return a generator object that's adheres to both the _iterable_ and _iterator_ protocols
@@ -268,7 +268,7 @@ Apologies about that long table of contents, and here we go.
268
268
269
269
- Follows the [`Promises/A+`][35] specification, was widely implemented in the wild before ES6 was standarized _(e.g [`bluebird`][34])_
270
270
- Promises behave like a tree. Add branches with `p.then(handler)` and `p.catch(handler)`
271
-
- Create new `p` promises with `new Promise(<mark>(resolve, reject) => { /* resolver */ }</mark>)`
271
+
- Create new `p` promises with `new Promise((resolve, reject) => { /* resolver */ })`
272
272
- The `resolve(value)` callback will fulfill the promise with the provided `value`
273
273
- The `reject(reason)` callback will reject `p` with a `reason` error
274
274
- You can call those methods asynchronously, blocking deeper branches of the promise tree
@@ -347,7 +347,7 @@ Apologies about that long table of contents, and here we go.
347
347
- Handlers are also known as traps, these terms are used interchangeably
348
348
- You can create **revocable** proxies with `Proxy.revocable(target, handler)`
349
349
- That method returns an object with `proxy` and `revoke` properties
350
-
- You could [destructure](#destructuring)`var <mark>{proxy, revoke}</mark> = Proxy.revocable(target, handler)` for convenience
350
+
- You could [destructure](#destructuring)`var {proxy, revoke} = Proxy.revocable(target, handler)` for convenience
351
351
- You can configure the `proxy` all the same as with `new Proxy(target, handler)`
352
352
- After `revoke()` is called, the `proxy` will **throw** on _any operation_, making it convenient when you can't trust consumers
353
353
-[`get`](https://ponyfoo.com/articles/es6-proxies-in-depth#get) -- traps `proxy.prop` and `proxy['prop']`
@@ -468,16 +468,16 @@ Apologies about that long table of contents, and here we go.
468
468
-[`export var foo = 'bar'`](https://ponyfoo.com/articles/es6-modules-in-depth#named-exports) exports a named binding
469
469
- Named exports are bindings that [can be changed](https://ponyfoo.com/articles/es6-modules-in-depth#bindings-not-values) at any time from the module that's exporting them
470
470
-`export { foo, bar }` exports [a list of named exports](https://ponyfoo.com/articles/es6-modules-in-depth#exporting-lists)
471
-
-`export { foo <mark>as ponyfoo</mark> }` aliases the export to be referenced as `ponyfoo` instead
472
-
-`export { foo <mark>as default</mark> }` marks the named export as the default export
471
+
-`export { foo as ponyfoo }` aliases the export to be referenced as `ponyfoo` instead
472
+
-`export { foo as default }` marks the named export as the default export
473
473
- As [a best practice](https://ponyfoo.com/articles/es6-modules-in-depth#best-practices-and-export), `export default api` at the end of all your modules, where `api` is an object, avoids confusion
474
474
- Module loading is implementation-specific, allows interoperation with CommonJS
475
475
-[`import 'foo'`](https://ponyfoo.com/articles/es6-modules-in-depth#import) loads the `foo` module into the current module
476
-
-[`import <mark>foo from</mark> 'ponyfoo'`](https://ponyfoo.com/articles/es6-modules-in-depth#importing-default-exports) assigns the default export of `ponyfoo` to a local `foo` variable
476
+
-[`import foo from 'ponyfoo'`](https://ponyfoo.com/articles/es6-modules-in-depth#importing-default-exports) assigns the default export of `ponyfoo` to a local `foo` variable
477
477
-[`import {foo, bar} from 'baz'`](https://ponyfoo.com/articles/es6-modules-in-depth#importing-named-exports) imports named exports `foo` and `bar` from the `baz` module
478
-
-`import {foo <mark>as bar</mark>} from 'baz'` imports named export `foo` but aliased as a `bar` variable
478
+
-`import {foo as bar} from 'baz'` imports named export `foo` but aliased as a `bar` variable
479
479
-`import {default} from 'foo'` also imports the default export
480
-
-`import {default <mark>as bar</mark>} from 'foo'` imports the default export aliased as `bar`
480
+
-`import {default as bar} from 'foo'` imports the default export aliased as `bar`
481
481
-`import foo, {bar, baz} from 'foo'` mixes default `foo` with named exports `bar` and `baz` in one declaration
482
482
-[`import * as foo from 'foo'`](https://ponyfoo.com/articles/es6-modules-in-depth#import-all-the-things) imports the namespace object
0 commit comments