Skip to content
0:00 / 0:00

#promises#es6#javascriptasync

JavaScript Promises In 10 Minutes

Web Dev Simplified

1.7M subscribers • 6 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Kyle Cook
  • May be out of date. Uploaded 7 years ago, in an area where tools change fast.

Beginner. No background in the topic needed.

1.9M views7 years ago1 recommendation

Programming languagesWeb developmentJavaScript

Kyle Cook explains how JavaScript Promises work, how to create them, and how to use them to avoid callback hell.

*Master JS array methods* with my *FREE JS Array Methods Cheat Sheet* - _20+ methods_ 👉 webdevsimplified.com/js-array-methods-cheat-sheet.html *Become a web developer* with my *FREE Web Development Roadmap* - _260+ videos, 120+ projects, 60+ articles_ 👉 webdevsimplified.com/web-dev-roadmap.html ES6 came with many new features, but one of the best features was the official introduction of Promises. Promises allow you to write clean non-callback-centric code without ever having to worry about callback hell. Even if you never write your own promise, knowing how they work is incredibly important, since many newer parts of the JavaScript API use promises instead of callbacks. Checkout the full video to learn how to define and use promises. Promise Article: blog.webdevsimplified.com/2021-09/javascript-promises Code From This Video: codepen.io/WebDevSimplified/pen/jXoXYj Twitter: twitter.com/DevSimplified GitHub: github.com/WebDevSimplified CodePen: codepen.io/WebDevSimplified #JavaScript #Promises #WebDevelopment

Why it's here

1 person recommends this

What people say. Recommended as a clear explanation of how JavaScript promises work and how to wrap asynchronous functions in them.

u/rster2002in r/node • Recommends

On “Retry loop with a pause between attempts”

Async await is only for when working with promises. setTimeout does not return a promise, so async await would not work. To get it to work you would have to create something like this: ```javascript const wait = delay => { return new Promise (res => { setTimeout(() { res(); }, delay); }); } // Your function await wait(2000); ``` Also, you'll need to make `waitForDevice` return a promise. ```javascript const wait = delay => { return new Promise(res => { setTimeout(() => { res(); }, delay); }); } const waitForDevice = (device) => { return new Promise(async (res, rej) => { // A promise exposes two functions: respond and reject // If you then performed…