Async JS Codevolution
Why async
How ?
Tradional Methdo of Js
setTimeout
To Clear a timeout use
It will ensure that greet function will not run after 2 sec duration
Remember to clear the interval esle it will run forever
2 cont... funtion will run only after call stack is free
CALLBACKS
Rewriting the code as per their names
Types of Call Back
Sycnhronus Callback
(Same as bove)
Async Callback
Here, the magic is there so learn it ,revise it
eg 2: addEventListener is HOF and the fn attaxched to event handler is the callback
as it will only be excute after it isbeen clicked
This becomes extremely unreadble so promises has been introduced
Promise
Howevver,
n
Comments
Post a Comment