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)

Declarative Versus Imperative


There are two general ways to think about writing code: Declarative and Imperative. Code written in the Functional Programming paradigm should be declarative.

Declarative code is code that expresses the logic of a computation without describing its control flow. Imperative code is code that uses statements to change a program's state.

These definitions are difficult to understand if you have never studied declarative and imperative code before. Declarative code is generally used with Functional Programming and imperative code is generally used with Object-Oriented Programming. There is no "right answer" when deciding which coding style to use; they both have their trade-offs. However, declarative code fits the Functional Programming paradigm better than imperative.

Imperative Functions

Imperative code is most common in OOP. The technical definition is complicated, but we can simplify it. An imperative approach to coding is about HOW you solve the problem. Consider...