Book Image

Advanced JavaScript

By : Zachary Shute
Book Image

Advanced JavaScript

By: Zachary Shute

Overview of this book

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.
Table of Contents (9 chapters)

Preface

About

This section briefly introduces the author, the coverage of this book, the technical skills you'll need to get started, and the hardware and software required to complete all of the included activities and exercises.

About the Book

JavaScript is a core programming language for web technology that can be used to modify both HTML and CSS. It is frequently abbreviated to just JS. JavaScript is used for processes that go on in the user interfaces of most web browsers, such as Internet Explorer, Google Chrome, and Mozilla Firefox. It is the most widely-used client-side scripting language today, due to its ability to make the browser do its work.

In this book, you will gain a deep understanding of JavaScript. You will learn how to write JavaScript in a professional environment using the new JavaScript syntax in ES6, how to leverage JavaScript's asynchronous nature using callbacks and promises, and how to set up test suites and test your code. You will be introduced to JavaScript's functional programming style and you will apply everything you learn to build a simple application in various JavaScript frameworks and libraries for backend and frontend development.

About the Author

Zachary Shute studied computer and systems engineering at RPI. He is now the lead full-stack engineer at a machine learning start-up in San Francisco, CA. For his company, Simple Emotion, he manages and deploys Node.js servers, a MongoDB database, and JavaScript and HTML websites.

Objectives

  • 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

Audience

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.

Approach

This book thoroughly explains the technology in an easy-to-understand way, while perfectly balancing theory and exercises. Each chapter is designed to build on what was learned in the previous chapter. The book contains multiple activities that use real-life business scenarios for you to practice and apply your new skills in a highly relevant context.

Minimum Hardware Requirements

For the optimal student experience, we recommend the following hardware configuration:

  • Processor: Intel Core i5 or equivalent

  • Memory: 4 GB RAM

  • Storage: 35 GB available space

  • An internet connection

Software Requirements

You'll also need the following software installed in advance:

Access to installation instructions can be provided separately to book material for large training centers and organizations. All source code is publicly available on GitHub and fully referenced within the training material.

Installing the Code Bundle

Copy the code bundle for the class to the C:/Code folder.

Additional Resources

The code bundle for this book is also hosted on GitHub at https://github.com/TrainingByPackt/Advanced-JavaScript.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The three ways to declare variables in JavaScript: var, let, and const."

A block of code is set as follows:

var example; // Declare variable
example = 5; // Assign value
console.log( example ); // Expect output: 5

Any command-line input or output is written as follows:

npm install babel --save-dev

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "This means that variables created with block scope are subject to the Temporal Dead Zone (TDZ)."

Installing Atom IDE

  1. To install Atom IDE, go to https://atom.io/ in your browser.

  2. Click on Download Windows Installer for Windows to download the setup file called AtomSetup-x64.exe.

  3. Run the executable file.

  4. Add the atom and apm commands to your path.

  5. Create shortcuts on the desktop and Start menu.

Babel is installed locally to each code project. To install Babel in a NodeJs project, complete the following steps:

  1. Open a command, line interface and navigate to a project folder.

  2. Run the command npm init command.

  3. Fill in all the required questions. If you are unsure about the meaning of any of the prompts, you can press the 'enter' key to skip the question and use the default value.

  4. Run the npm install --save-dev babel-cli command.

  5. Run the command install --save-dev babel-preset-es2015.

  6. Verify that the devDependencies field in package.json has babel-cli and babel-presets-es2015.

  7. Create a file called .babelrc.

  8. Open this file in a text editor and add the code { "presets": ["es2015"] }.

Installing Node.js and npm

  1. To install Node.js, go to https://nodejs.org/en/ in your browser.

  2. Click on Download for Windows (x64), to download the LTS setup file recommended for most users called node-v10.14.1-x64.msi.

  3. Run the executable file.

  4. Ensure that you select the npm package manager bundle during the setup.

  5. Accept the license and default installation settings.

  6. Restart your computer for the changes to take effect.