Promises, Async Await keywords - LECTURE 2 | JavaScript Full Course | JavaScript for Beginners | #js

preview_player
Показать описание
Completion (or failure) of an asynchronous


A Javascript promise can be fulfilled, rejected, or pending
Promises
While a Promise object is "pending" (working), the result is

undefined.

When a Promise object is "fulfilled", the result is a value.
When a Promise object is "rejected", the result is an error

object.

filename=tryjs_promise2


Promises Convert callback to promise
setTimeout(function() { myFunction(“hello
world!!!"); }, 3000);
function myFunction(value) {
}


Async/Await
"async and await make promises easier to write” - async makes a function return a Promise

syntactic sugar
await makes a function wait for a Promise. You

don’t need the `.then()` syntax

▶️ You Can Find Us On:

#javascript #jsprogramming #programmers #github #coding #nodejs #reactjs #codinglife #html #coder
Рекомендации по теме
visit shbcf.ru