9781680502886
Simplifying JavaScript: Writing Modern JavaScript with ES5,ES6,and Beyond
by 作者: Joe Morgan
ISBN-10 书号: 1680502883
ISBN-13 书号: 9781680502886
Edition 版本: 1
Publisher Finelybook 出版日期: 2018-04-27
Pages: 284
The best modern JavaScript is simple,readable,and predictable. Learn to write modern JavaScript not by memorizing a list of new syntax,but with practical examples of how syntax changes can make code more expressive. Starting from variable declarations that communicate intention clearly,see how modern principles can improve all parts of code. Incorporate ideas with curried functions,array methods,classes,and more to create code that does more with less while yielding fewer bugs.
It’s time to write JavaScript code that’s clean and exprssive. Modern JavaScript is simpler and more predictable and readable than ever. Discover how to write better code with clear examples using principles that show how updated syntax can make code better with fewer bugs.
Starting from the ground up,learn new syntax (or how to reuse older syntax) to transform code from clunky bug-susceptible scripts to clear and elegant programs that are easy to read and easy to extend.
Create a foundation for readable code with simple variable declarations that reduce side effects and subtle bugs. Select collections with clear goals instead of defaulting to objects or arrays. See how to simplify iterations from complex loops to single line array methods. Master techniques for writing flexible and solid code ranging from high-order functions,to reusableclasses,to patterns for architecting large applications creating applications that will last while through rounds of refactoring and changing requirements.
The best part is there’s no need to read this book straight through. Jump around and incorporate new functionality at will. Most importantly,understand not just what the new syntax is,but when and how to use it. Start writing better code from the first page.
What You Need:
For the best experience,have the latest version of Node installed (at least version 7). You can test most examples in the console of Chrome or other modern web browser. If you’d like to run the tests,you’ll also need to install the latest version of Node Package Manager (npm).Introduction
Chapter 1: Signal Intention with Variable Assignment
Signal Unchanging Values with const
Reduce Scope Conflicts with letand const
Isolate Information with Block Scoped Variables
Convert Variables to Readable Strings with Template Literals
Chapter 2: Manage Data Collections with Arays
Create Flexible Collections with Arrays
Check Existence in an Array with Includes)
Mold Arrayswith the Spread Operator
Avoid Push Mutations with the Spread Operator
Avoid Sort Confusion with the Spread Operator
Chapter 3: Maximize Code Clarity with Special Collections
Use Objects for Static Key-Value Lookups
Create Objects Without Mutations Using Object. assign0
Update Information with Object Spread
Update Key-Value Data Clearly with Maps
erate Over Key-Value Data with Map and the Spread Operator
Create Maps Without Side Effects
Keep Unique Values with Set
Chapter 4: Write Clear Conditionals
Shorten Conditionals with Falsy Values
Check Data Quickly with the Ternary Operator
Maximize Efficiency with Short Circuiting
Chapter 5: Simplifly Loops
Simplify Looping with Arrow Functions
Write Shorter Loops with Array Methods
Create Arrays of a Similar Size with map0
Pull Out Subsets of Data with filter0 andfind0
Apply Consistent Actions with forEach)
Combine Methods with Chaining
Transform Array Data with reduce0
Reduce Loop Clutter with for.. in and for.. each
Chapter 6: Clean Up Parameters and Return Statements
Create Default Parameters
Access Object Properties with Destructuring
Simplify Key-Value Assignment
Pass a Variable Number of Arguments with the Rest Operator
Chapter 7: Build Flexible Functions
Write Functions for Testability
Reduce Complexity with Arrow Functions
Maintain Single Responsibility Parameters with Partially Applied Functions
Combine Curying and Array Methods for Partial Application
Prevent Context Confusion with Arow Functions
Chapter 8: Keep Interfaces Clear with Classes
Build Readable Classes
Share Methods with Inheritance
ExtendExisting Prototypes with Class
Simplify Interfaces with getand set
Create lterable Properties with Generators
Resolve Context Problems with Bind)
Chapter 9: Access External Data
Retrieve Data Asynchronously with Promises
Create Clean Functions with Async/Await
Make Simple AJAX Calls with Fetch
Maintain State Over Time with LocalStorage
Chapter 10: Gather Related Files with Component Architecture
lsolate Functionality with Import and Export
Leverage Community Knowledge with npm
Build Applications with Component Architecture
Use Build Tools to Combine Components
Leverage CSS for Animations
Introduction
1.Signal Intention with Variable Assignment
2.Manage Data Collections with Arrays
3.Maximize Code Clarity with Special Collections
4.Write Clear Conditionals
5.Simplify Loops
6.Clean Up Parameters and Return Statements
7.Build Flexible Functions
8.Keep Interfaces Clear with Classes
9.Access External Data
10.Gather Related Files with Component Architecture
Bibliography