This promise technique is important to understand in javascript #shorts

preview_player
Показать описание
Sharing how to wrap promises in javascript. Useful when dealing with callbacks

My VSCode Extensions:
- theme: material community high contrast
- fonts: Menlo, Monaco, 'Courier New', monospace
- errors: Error Lens
- extra git help: Git Lens
- tailwind css intellisense
- indent rainbow
- material icon theme
- prettier & eslint
- ES7+ React Snippets

------------

Рекомендации по теме
Комментарии
Автор

Holy fucking damn…. A short in 30 seconds was the best explanation for the promise I never learned in JavaScript 💀

jugertmucoimaj
Автор

I got so confused because I couldn't just await for it, tnx!

koi
Автор

Explaining these stuffs so clearly is an art

AntonioSantos-vezv
Автор

Nice, the tips are getting more advanced and interesting now

mrs
Автор

OMG!!!! you just taught me in 30 seconds which I was trying to wrap my head around since 1 yr!!! JS GOD🙏

kalonacharjee
Автор

love your shorts! this one's just great! thank you

danieljulien
Автор

your channel is so underrated. I hope this blows up sometime in future

mohammadkaif
Автор

Never properly get around those promises, seemed complicated and had no time, but this video finally let me catch the gist!

maksym.pryhoda
Автор

Great video today. More of these high level ones please.

hass
Автор

This is an area where we need more shorts, these are great, many people lack the understanding in this areas.

BarisPalabiyik
Автор

great and simple explanation of the promise, thanks

HasanAYousef
Автор

I actually had to do this for the first time earlier today. Interesting that I got a video recommended on that exact same thing just after.

Xevion
Автор

that was short, sweet, and straight to the point. great video

iwatchtoomuchhaikyuu
Автор

Crazy I was just doing this today and had this exact issue you described. Nice video.

ChillAutos
Автор

In case if anyone didn't understand how World was printed first:
1. It will register setTimeout Callback fn in Web API environment.
2. It'll print World
3. As soon as world is printed i.e. Global Execution Context is popped from Call Stack.
4. After 1 sec our registered callback fn will be pushed inside Task Queue.
5. Event Loop will check whether Call Stack is empty or not, in this scenario Call Stack was emptied when World was logged into console.
6. Now, callback fn i.e. setTimeout Callback fn will be popped from Task Queue and Pushed inside Call Stack.
7. Hello is printed
8. Callback fn execution context is popped from Call Stack.

prasadsawant
Автор

Also, for setTimeout specifically I find it super useful to make a “sleep” helper for when you intentionally just want to wait a bit:

const sleep = ms => new Promise(r => setTimeout(r, ms))

Then you can use it like this:

console.log(‘hello’)
await sleep(1000)
console.log(‘world’)

___jd
Автор

Would love to see more advanced stuff like this. Very cool vid

cwyrwas
Автор

So basically people don't know what Promise is, but they use the async keyword willy-nilly...

PaulSebastianM
Автор

I have done a paid course on js and yet a 30-sec video on promise cleared my whole existence

keshavakumar
Автор

I encountered this exact issue when working with the mysql npm pkg. I did just that. Promises to the resque😊

deezydoezeet