JavaScript: Best Practices for Functions and Classes

JavaScript: Best Practices for Functions and Classes

English | MP4 | AVC 1280×720 | AAC 48KHz 2ch | 1h 45m | 333 MB

JavaScript uses C-based syntax, but the structures at its core, namely functions and classes, behave very differently than C behaves. Leveraging recommended techniques can help you develop JavaScript code that is more consistent and easier to maintain. In this course, explore best practices for architecting your programs. Consider ways that details can take paths that differ from other programming languages. Learn about creating well-built, organized, modular, and high-quality code by using a style guide, modern deployment tools, and strict mode. Discover how to carefully construct functions using more predictable expressions over declarations and by avoiding the modification of parameter values. Examine the dos—and don’ts—of “this” values and learn about which JavaScript features to avoid.

Table of Contents

1 Creating well-structured modular JavaScript
2 What you should know
3 Setting up your environment
4 Understanding style guides
5 Using modern deployment tools
6 Understanding ESLint
7 Foundational practice Always use strict mode
8 Use function expressions instead of declarations
9 Don’t use the new keyword to construct functions
10 Leave parameter values untouched
11 Use arrow syntax for anonymous functions
12 Rely on implicit return only when obvious
13 Challenge Create functions
14 Solution Create functions
15 Use PascalCase for naming classes and constructors
16 Use this only in classes or constructors
17 Return this from methods
18 Don’t assign this to another variable
19 Challenge Create classes
20 Solution Create classes
21 Configure module settings in ESLint
22 Default export constants when possible
23 Use case to indicate a module’s default export type
24 Use object destructuring
25 Use array destructuring
26 Challenge Destructure
27 Solution Destructure
28 Avoid eval
29 Avoid == and !=
30 Avoid with
31 Avoid unary increments and decrements
32 Next steps