• Complain

Nicholas C Zakas - Understanding JavaScript Promises

Here you can read online Nicholas C Zakas - Understanding JavaScript Promises full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2022, publisher: Lulu.com, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Understanding JavaScript Promises
  • Author:
  • Publisher:
    Lulu.com
  • Genre:
  • Year:
    2022
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Understanding JavaScript Promises: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Understanding JavaScript Promises" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Since promises were added to JavaScript in 2015, they have become an integral part of the language. A good understanding of how promises work is more important than ever in becoming a proficient JavaScript developer. This book begins by explaining the basic concepts behind promises, including what they are, how to use them, and how to create your own. Youll then build upon these basic concepts to learn how to chain promises together and how to respond to multiple promises at once. Once youve learned these advanced concepts, youll move on to learn how promises work with async functions and how to track unhandled promise rejections. All of the concepts discussed are grounded in real world examples so you learn not just how to use a particular technique, but also why and when to use it. It doesnt matter if youre writing JavaScript for web browsers, Node.js, or Deno, this book will teach you everything you need to know about promises.

Nicholas C Zakas: author's other books


Who wrote Understanding JavaScript Promises? Find out the surname, the name of the author of the book and a list of all author's works by series.

Understanding JavaScript Promises — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Understanding JavaScript Promises" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Understanding JavaScript Promises Nicholas C Zakas This book is for sale at - photo 1
Understanding JavaScript Promises
Nicholas C. Zakas

This book is for sale at http://leanpub.com/understanding-javascript-promises

This version was published on 2022-02-19

This is a Leanpub book Leanpub empowers authors and publishers with - photo 2

* * * * *

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do.

* * * * *

2020 - 2022 Nicholas C. Zakas

ISBN for EPUB version: 978-1-6781-2066-5

Introduction

One of the most powerful aspects of JavaScript is how easily it handles asynchronous programming. As a language created for the web, JavaScript needed to respond to user interactions such as clicks and key presses from the beginning, and so event handlers such as onclick were created. Event handlers allowed developers to specify a function to execute at some later point in time in reaction to an event.

Node.js further popularized asynchronous programming in JavaScript by using callback functions in addition to events. As more and more programs started using asynchronous programming, events and callbacks were no longer sufficient to support everything developers wanted to do. Promises are the solution to this problem.

Promises are another option for asynchronous programming, and they work like futures and deferreds do in other languages. A promise specifies some code to be executed later (as with events and callbacks) and also explicitly indicates whether the code succeeded or failed at its job. You can chain promises together based on success or failure in ways that make your code easier to understand and debug.

About This Book

The goal of this book is to explain how JavaScript promises work while giving practical examples of when to use them. All new asynchronous JavaScript APIs will be built with promises going forward, and so promises are a central concept to understanding JavaScript as a whole. My hope is that this book will give you the information you need to successfully use promises in your projects.

Browser, Node.js, and Deno Compatibility

There are multiple JavaScript runtimes that you may use, such as web browsers, Node.js, and Deno. This book doesnt attempt to address differences between these JavaScript runtimes unless they are so different as to be confusing. In general, this book focuses on promises as described in ECMA-262 and only talks about differences in JavaScript runtimes when they are substantially different. As such, its possible that your JavaScript runtime may not conform to the standards-based behavior described in this book.

Who This Book Is for

This book is intended as a guide for those who are already familiar with JavaScript. In particular, this book is aimed at intermediate-to-advanced JavaScript developers who work in web browsers, Node.js, or Deno and who want to learn how promises work.

This book is not for beginners who have never written JavaScript. You will need to have a good, basic understanding of the language to make use of this book.

Overview

Each of this books five chapters covers a different aspect of JavaScript promises. Many chapters cover promise APIs directly, and each chapter builds upon the preceding chapters in a way that allows you to build up your knowledge gradually. All chapters include code examples to help you learn new syntax and concepts.

Chapter 1: Promise Basics introduces the concept of promises, how they work, and different ways to create and use them.

Chapter 2: Chaining Promises discusses the various ways to chain multiple promises together to make composing asynchronous operations easier.

Chapter 3: Working with Multiple Promises explains the built-in JavaScript methods designed to monitor and respond to multiple promises executing in parallel.

Chapter 4: Async Functions and Await Expressions introduces the concepts of async functions and await expressions, and explains how they relate to and use promises.

Chapter 5: Unhandled Rejection Tracking explains how to properly track when promises are rejected without a rejection handler.

Conventions Used

The following typographical conventions are used in this book:

  • Italics introduces new terms
  • Constant width indicates a piece of code or filename

All JavaScript code examples are written as modules (also known as ECMAScript modules or ESM).

Additionally, longer code examples are contained in constant width code blocks such as:

1functiondoSomething(){2// empty3}

Within a code block, comments to the right of a console.log() statement indicate the output youll see in the browser or Node.js console when the code is executed. For example:

1console.log("Hi");// "Hi"

If a line of code in a code block throws an error, this is also indicated to the right of the code:

1doSomething();// error!
Help and Support

If you have questions as you read this book, please send a message to my mailing list: books@humanwhocodes.com. Be sure to mention the title of this book in your subject line.

Acknowledgments

Im grateful to my father, Speros Zakas, for copyediting this book and for Rob Friesels technical editing. You both have made this book much better than it was.

Thanks to everyone who reviewed early versions of this book and provided feedback: Mike Sherov, David Hund, Murat Corlu, and Chris Ferdinandi.

About the Author

Nicholas C. Zakas is an independent software engineer, consultant, and coach. He is the creator of the ESLint open source project and serves on the ESLint Technical Steering Committee. Nicholas works with companies and individuals to improve software engineering processes and helps technical leaders grow and succeed. He has also authored or contributed to over a dozen books related to JavaScript and web development. You can find Nicholas online at https://humanwhocodes.com and on Twitter @slicknet.

Disclaimer

While the publisher and the author have used good faith effort to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.

1. Promise Basics

While promises are often associated with asynchronous operations, they are simply placeholders for values. The value may already be known or, more commonly, the value may be the result of an asynchronous operation. Instead of subscribing to an event or passing a callback to a function, a function can return a promise, like this:

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Understanding JavaScript Promises»

Look at similar books to Understanding JavaScript Promises. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Understanding JavaScript Promises»

Discussion, reviews of the book Understanding JavaScript Promises and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.