filmov
tv
JS Promises & Async/Await: What you NEED to know
![preview_player](https://i.ytimg.com/vi/ab3ZFyeBUhw/maxresdefault.jpg)
Показать описание
JavaScript's problem is that it is single-threaded.
What do we mean by that? It means that if it does something that takes time - an intensive calculation for example - the JS engine cannot do anything else at the same time.
Sometimes I code a "while" block and I forget to do anything to the variable on which I wrote the condition. And so I create an infinite loop. When I do this, … everything freezes. The browser doesn't respond anymore, I have to force the window to close. This is an extreme case, but as you probably know, movies run at 24 frames per second, and video games at 60 FPS or more. But 24 frames per second means one frame every 40 milliseconds or so. (1/24 = 0.0416 )
So any process or calculation in #JavaScript must get the job done in 40 milliseconds or less. Otherwise, users will get the impression that the application is "lagging".
But if you want to call an API, on a web server, the message's round trip is bound to take longer than that. And JavaScript just can't afford to wait. So we need to find ways to tell it to go and do other stuff while waiting.
The solution.. is #Promises.
What do we mean by that? It means that if it does something that takes time - an intensive calculation for example - the JS engine cannot do anything else at the same time.
Sometimes I code a "while" block and I forget to do anything to the variable on which I wrote the condition. And so I create an infinite loop. When I do this, … everything freezes. The browser doesn't respond anymore, I have to force the window to close. This is an extreme case, but as you probably know, movies run at 24 frames per second, and video games at 60 FPS or more. But 24 frames per second means one frame every 40 milliseconds or so. (1/24 = 0.0416 )
So any process or calculation in #JavaScript must get the job done in 40 milliseconds or less. Otherwise, users will get the impression that the application is "lagging".
But if you want to call an API, on a web server, the message's round trip is bound to take longer than that. And JavaScript just can't afford to wait. So we need to find ways to tell it to go and do other stuff while waiting.
The solution.. is #Promises.
The Async Await Episode I Promised
JavaScript Promise in 100 Seconds
Asynchronous JavaScript in ~10 Minutes - Callbacks, Promises, and Async/Await
Async JS Crash Course - Callbacks, Promises, Async Await
JavaScript ASYNC/AWAIT is easy! ⏳
Asynchronous JavaScript Course (Async/Await, Promises, Callbacks)
Async Await vs. Promises - JavaScript Tutorial for beginners
JavaScript Async/Await Simply Explained
Mastering JavaScript Promises in 1 Hour: Resolve, Reject & Async Await Explained!
Asynchronous JavaScript Course – Async/Await , Promises, Callbacks, Fetch API
Lecture 12 : Callbacks, Promises & Async Await | JavaScript Full Course
JavaScript Async Await
JavaScript Promises In 10 Minutes
Como usar Async/Await? Promises no JavaScript? Você NUNCA MAIS VAI ERRAR
Difference Between callback Promises Async/Await in JavaScript | Interview Question
JavaScript Promises -- Tutorial for Beginners
Async Await try-catch hell
JS Assíncrono: Entenda de vez Callbacks, Promises e Async/Await
Просто o async, await. Без циклов и таймеров. JavaScript
Урок 5. JavaScript. Promise. Что это, как работает (+ пример)
Asynchronous Javascript Tutorial - Promises and Async Await Explained
Promises Explained For Beginners | Async-Await & Promise | Web Development Course #45
Урок 8. JavaScript. Как работает Async, Await. Работа с сервером c fetch...
Full Course: Javascript Asynchronous
Комментарии