Skip to content

Commit 5508453

Browse files
committed
Adding shortcut back to Table of Contents
1 parent 7289d14 commit 5508453

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ This change in behavior highlights that we need to be careful when refactoring l
5858

5959
> **Best Practice**: Leave **var** declarations inside of legacy code to denote that it needs to be carefully refactored. When working on a new codebase, use **let** for variables that will change their value over time, and **const** for variables that will be immutable over time.
6060
61+
<sup>[(back to table of contents)](#table-of-contents)</sup>
62+
6163
## Replacing IIFEs with Blocks
6264

6365
> A common use of **Immediately Invoked Function Expressions** is to enclose values within its scope. In ES6, we now have the ability to create block-based scopes and therefore are not limited purely to function-based scope.
@@ -78,6 +80,8 @@ Using ES6 Blocks:
7880
console.log(food); // Reference Error
7981
```
8082

83+
<sup>[(back to table of contents)](#table-of-contents)</sup>
84+
8185
## Arrow Functions
8286

8387
Often times we have nested functions in which we would like to preserve the context of **this** from it's lexical scope. An example is shown below:
@@ -136,6 +140,8 @@ const squares = arr.map(x => x * x); // Arrow Function for terser implementation
136140

137141
> **Best Practice**: Use **Arrow Functions** in place of function expressions when possible.
138142
143+
<sup>[(back to table of contents)](#table-of-contents)</sup>
144+
139145
## Strings
140146

141147
With ES6, the standard library has grown immensely. Along with these changes are new methods which can be used on strings, such as **.includes()** and **.repeat()**.
@@ -240,6 +246,8 @@ let today = new Date()
240246
let text = `The time and date is ${today.toLocaleString()}`
241247
```
242248

249+
<sup>[(back to table of contents)](#table-of-contents)</sup>
250+
243251
## Destructuring
244252

245253
Destructuring allows us to extract values from arrays and objects (even deeply nested) and store them in variables with a more convient syntax.
@@ -275,6 +283,8 @@ console.log(occupation); // 'jedi'
275283
console.log(father); // 'anakin'
276284
```
277285

286+
<sup>[(back to table of contents)](#table-of-contents)</sup>
287+
278288
## Modules
279289

280290
Prior to ES6, we used libraries such as [Browserify](http://browserify.org/) to create modules on the client-side, and [require](https://nodejs.org/api/modules.html#modules_module_require_id) in **Node.js**. With ES6, we can now directly use modules of all types (AMD and CommonJS).
@@ -377,6 +387,8 @@ import * as util from 'math/addition'
377387

378388
> **Note**: Values that are exported are **bindings**, not references. Therefore, changing the binding of a variable in one module will affect the value within the exported module. Avoid changing the public interface of these exported values.
379389
390+
<sup>[(back to table of contents)](#table-of-contents)</sup>
391+
380392
## Parameters
381393

382394
In ES5, we had varying ways to handle functions which needed **default values**, **indefinite arguments**, and **named parameters**. With ES6, we can accomplish all of this and more using more concise syntax.
@@ -466,6 +478,8 @@ We can use the spread operator to pass an array of values to be used as paramete
466478
Math.max(...[-1, 100, 9001, -32]) // 9001
467479
```
468480

481+
<sup>[(back to table of contents)](#table-of-contents)</sup>
482+
469483
## Classes
470484

471485
Prior to ES6, we implemented Classes by creating a constructor function and adding properties by extending the prototype:
@@ -534,6 +548,8 @@ class Personal extends Person {
534548

535549
> **Best Practice**: While the syntax for creating classes in ES6 obscure how implementation and prototypes work under the hood, it is a good feature for beginners and allows us to write cleaner code.
536550
551+
<sup>[(back to table of contents)](#table-of-contents)</sup>
552+
537553
## Symbols
538554

539555
Symbols have existed prior to ES6, but now we have a public interface to using them directly. One such example is to create unique property keys which will never collide:
@@ -551,6 +567,8 @@ object.keyTwo = 'Much Uniqueness'
551567
>> false
552568
```
553569

570+
<sup>[(back to table of contents)](#table-of-contents)</sup>
571+
554572
## Maps
555573

556574
**Maps** is a much needed data structure in JavaScript. Prior to ES6, we created **hash** maps through objects:
@@ -602,6 +620,8 @@ for (let [key, value] of map.entries()) {
602620
}
603621
```
604622

623+
<sup>[(back to table of contents)](#table-of-contents)</sup>
624+
605625
## WeakMaps
606626

607627
In order to store private data in < ES5, we had various ways of doing this. One such method was using naming conventions:
@@ -644,6 +664,8 @@ The cool thing about using WeakMaps to store our private data is that their keys
644664
> Reflect.ownKeys(person); // []
645665
```
646666

667+
<sup>[(back to table of contents)](#table-of-contents)</sup>
668+
647669
## Promises
648670

649671
Promises allow us to turn our horizontal code (callback hell):

0 commit comments

Comments
 (0)