Advanced JavaScript

Book description

Gain a deeper understanding of JavaScript and apply it to build small applications in backend, frontend, and mobile frameworks.

Key Features

  • Explore the new ES6 syntax, the event loop, and asynchronous programming
  • Learn the test-driven development approach when building apps
  • Master advanced JavaScript concepts to enhance your web developments skill

Book Description

If you are looking for a programming language to develop flexible and efficient applications, JavaScript is an obvious choice. Advanced JavaScript is a hands-on guide that takes you through JavaScript and its many features, one step at a time. You'll begin by learning how to use the new JavaScript syntax in ES6, and then work through the many other features that modern JavaScript has to offer. As you progress through the chapters, you'll use asynchronous programming with callbacks and promises, handle browser events, and perform Document Object Model (DOM) manipulation. You'll also explore various methods of testing JavaScript projects. In the concluding chapters, you'll discover functional programming and learn to use it to build your apps. With this book as your guide, you'll also be able to develop APIs using Node.js and Express, create front-ends using React/Redux, and build mobile apps using React/Expo.

By the end of Advanced JavaScript, you will have explored the features and benefits of JavaScript to build small applications.

What you will learn

  • Examine major features in ES6 and implement those features to build applications
  • Create promise and callback handlers to work with asynchronous processes
  • Develop asynchronous flows using Promise chaining and async/await syntax
  • Manipulate the DOM with JavaScript
  • Handle JavaScript browser events
  • Explore Test Driven Development and build code tests with JavaScript code testing frameworks.
  • List the benefits and drawbacks of functional programming compared to other styles
  • Construct applications with the Node.js backend framework and the React frontend framework

Who this book is for

This book is designed to target anyone who wants to write JavaScript in a professional environment. We expect the audience to have used JavaScript in some capacity and be familiar with the basic syntax. This book would be good for a tech enthusiast wondering when to use generators or how to use Promises and Callbacks effectively, or a novice developer who wants to deepen their knowledge on JavaScript and understand TDD.

Table of contents

  1. Preface
    1. About the Book
      1. About the Author
      2. Objectives
      3. Audience
      4. Approach
      5. Minimum Hardware Requirements
      6. Software Requirements
      7. Installing the Code Bundle
      8. Additional Resources
      9. Conventions
      10. Installing Atom IDE
      11. Installing Node.js and npm
  2. Chapter 1
  3. Introducing ECMAScript 6
    1. Introduction
    2. Beginning with ECMAScript
    3. Understanding Scope
      1. Function Scope
      2. Function Scope Hoisting
      3. Block Scope
      4. Exercise 1: Implementing Block Scope
    4. Declaring Variables
      1. Exercise 2: Utilizing Variables
    5. Introducing Arrow Functions
      1. Exercise 3: Converting Arrow Functions
      2. Arrow Function Syntax
      3. Exercise 4: Upgrading Arrow Functions
    6. Learning Template Literals
      1. Exercise 5: Converting to Template Literals
      2. Exercise 6: Template Literal Conversion
    7. Enhanced Object Properties
      1. Object Properties
      2. Function Declarations
      3. Computed Properties
      4. Exercise 7: Implementing Enhanced Object Properties
    8. Destructuring Assignment
      1. Array Destructuring
      2. Exercise 8: Array Destructuring
      3. Rest and Spread Operators
      4. Object Destructuring
      5. Exercise 9: Object Destructuring
      6. Exercise 10: Nested Destructuring
      7. Exercise 11: Implementing Destructuring
    9. Classes and Modules
      1. Classes
      2. Exercise 12: Creating Your Own Class
      3. Classes – Subclasses
      4. Modules
      5. Export Keyword
      6. Import Keyword
      7. Exercise 13: Implementing Classes
    10. Transpilation
      1. Babel- Transpiling
      2. Exercise 14: Transpiling ES6 Code
    11. Iterators and Generators
      1. Iterators
      2. Generators
      3. Exercise 15: Creating a Generator
      4. Activity 1: Implementing Generators
    12. Summary
  4. Chapter 2
  5. Asynchronous JavaScript
    1. Introduction
    2. Asynchronous Programming
      1. Sync Versus Async
      2. Synchronous versus Asynchronous Timing
      3. Introducing Event Loops
      4. Stack
      5. Heap and Event Queue
      6. Event Loops
      7. Things to Consider
      8. Exercise 16: Handling the Stack with an Event Loop
    3. Callbacks
      1. Building Callbacks
      2. Callback Pitfalls
      3. Fixing Callback Hell
      4. Exercise 17: Working with Callbacks
    4. Promises
      1. Promises States
      2. Resolving or Rejecting a Promise
      3. Using Promises
      4. Exercise 18: Creating and Resolving Your First Promise
      5. Handling Promises
      6. Promise Chaining
      7. Promises and Callbacks
      8. Wrapping Promises in Callbacks
      9. Exercise 19: Working with Promises
    5. Async/Await
      1. Async/Await Syntax
      2. Asnyc/Await Promise Rejection
      3. Using Async Await
      4. Activity 2: Using Async/Await
    6. Summary
  6. Chapter 3
  7. DOM Manipulation and Event Handling
    1. Introduction
    2. DOM Chaining, Navigation, and Manipulation
      1. Exercise 20: Building the HTML Document from a DOM Tree Structure
      2. DOM Navigation
      3. Finding a DOM Node
      4. Traversing the DOM
      5. DOM Manipulation
      6. Updating Nodes in the DOM
      7. Updating Nodes in the DOM
      8. Exercise 21: DOM Manipulation
    3. DOM Events and Event Objects
      1. DOM Event
      2. Event Listeners
      3. Event Objects and Handling Events
      4. Event Propagation
      5. Firing Events
      6. Exercise 22: Handling Your First Event
      7. Custom Events
      8. Exercise 23: Handling and Delegating Events
    4. JQuery
      1. jQuery Basics
      2. jQuery Selector
      3. jQuery DOM Manipulation
      4. Selecting Elements
      5. Traversing the DOM
      6. Modifying the DOM
      7. Chaining
      8. jQuery Events
      9. Firing Events
      10. Custom Events
      11. Activity 3: Implementing jQuery
    5. Summary
  8. Chapter 4
  9. Testing JavaScript
    1. Introduction
    2. Testing
      1. Reasons to Test Code
      2. Test-driven Development
      3. TDD Cycle
      4. Conclusion
      5. Exercise 24: Applying Test-Driven Development
    3. Types of Testing
      1. Black Box and White Box Testing
      2. Unit Tests
      3. Exercise 25: Building Unit Tests
      4. Functional Testing
      5. Integration Tests
      6. Building Tests
      7. Exercise 26: Writing Tests
    4. Test Tools and Environments
      1. Testing Frameworks
      2. Mocha
      3. Setting Up Mocha
      4. Mocha Basics
      5. Exercise 27: Setting Up a Mocha Testing Environment
      6. Mocha Async
      7. Mocha Hooks
      8. Activity 4: Utilizing Test Environments
    5. Summary
  10. Chapter 5
  11. Functional Programming
    1. Introduction
    2. Introducing Functional Programming
      1. Object-Oriented Programming
      2. Functional Programming
    3. Declarative Versus Imperative
      1. Imperative Functions
      2. Declarative Functions
      3. Exercise 28: Building Imperative and Declarative Functions
    4. Pure Functions
      1. Same Output Given Same Input
      2. No Side Effects
      3. Referential Transparency
      4. Exercise 29: Building Pure Controllers
    5. Higher Order Functions
      1. Exercise 30: Editing Object Arrays
    6. Shared State
      1. Exercise 31: Fixing Shared States
    7. Immutability
      1. Immutability in JavaScript
    8. Side Effects
      1. Avoiding Side Effects
    9. Function Composition
      1. Activity 5: Recursive Immutability
    10. Summary
  12. Chapter 6
  13. The JavaScript Ecosystem
    1. Introduction
    2. JavaScript Ecosystem
      1. Frontend JavaScript
      2. Command-Line Interface
      3. Mobile Development
      4. Backend Development
    3. Node.js
      1. Setting Up Node.js
      2. Node Package Manager
      3. Loading and Creating Modules
      4. Exercise 32: Exporting and Importing NPM Modules
      5. Basic Node.js Server
      6. Exercise 33: Creating a Basic HTTP Server
      7. Streams and Pipes
      8. Types of Streams
      9. Writeable Stream Events:
      10. Readable Stream Events:
      11. Filesystem Operations
      12. Express Server
      13. Exercise 34: Creating a Basic Express Server
      14. Routing
      15. Advanced Routing
      16. Middleware
      17. Error Handling
      18. Exercise 35: Building a Backend with Node.js
    4. React
      1. Installing React
      2. React Basics
      3. React Specifics
      4. JSX
      5. ReactDOM
      6. React.Component
      7. State
      8. Conditional Rendering
      9. List of Items
      10. HTML Forms
      11. Activity 6: Building a Frontend with React
    5. Summary
  14. Appendix
    1. Chapter 1: Introducing ECMAScript 6
      1. Activity 1 – Implementing Generators
    2. Chapter 2: Asynchronous JavaScript
      1. Activity 2 – Using Async/Await
    3. Chapter 3: DOM Manipulation and Event Handling
      1. Activity 3 – Implementing jQuery
    4. Chapter 4: Testing JavaScript
      1. Activity 4 – Utilizing Test Environments
    5. Chapter 5: Functional Programming
      1. Activity 1 – Recursive Immutability
    6. Chapter 6: JavaScript Ecosystem
      1. Activity 6 – Building a Frontend with React

Product information

  • Title: Advanced JavaScript
  • Author(s): Zachary Shute
  • Release date: January 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789800104