What are JavaScript PROMISES? 🤞

  Рет қаралды 39,494

Bro Code

Bro Code

5 ай бұрын

#JavaScript #tutorial #courses
// Promise = An Object that manages asynchronous operations.
// Wrap a Promise Object around {asynchronous code}
// "I promise to return a value"
// DO THESE CHORES IN ORDER
// 1. WALK THE DOG
// 2. CLEAN THE KITCHEN
// 3. TAKE OUT THE TRASH

Пікірлер: 43
@BroCodez
@BroCodez 5 ай бұрын
// Promise = An Object that manages asynchronous operations. // Wrap a Promise Object around {asynchronous code} // "I promise to return a value" // PENDING -> RESOLVED or REJECTED // new Promise((resolve, reject) => {asynchronous code}) // DO THESE CHORES IN ORDER // 1. WALK THE DOG // 2. CLEAN THE KITCHEN // 3. TAKE OUT THE TRASH function walkDog(){ return new Promise((resolve, reject) => { setTimeout(() => { const dogWalked = false; if(dogWalked){ resolve("You walk the dog 🐕"); } else{ reject("You DIDN'T walk the dog"); } }, 1500); }); } function cleanKitchen(){ return new Promise((resolve, reject) => { setTimeout(() => { const kitchenCleaned = true; if(kitchenCleaned){ resolve("You clean the kitchen 🧹"); } else{ reject("You DIDN'T clean the kitchen"); } }, 2500); }); } function takeOutTrash(){ return new Promise((resolve, reject) => { setTimeout(() => { const trashTakenOut = true; if(trashTakenOut){ resolve("You take out the trash ♻"); } else{ reject("You DIDN'T take out the trash"); } }, 500); }); } walkDog().then(value => {console.log(value); return cleanKitchen()}) .then(value => {console.log(value); return takeOutTrash()}) .then(value => {console.log(value); console.log("You finished all the chores!")}) .catch(error => console.error(error));
@hamodi20091
@hamodi20091 5 ай бұрын
Finally, I understand PROMISES. Thanks
@SaintHanappi
@SaintHanappi 5 ай бұрын
Take out the trash "is really quick" => open the window/door - throw the trash - close. 🙊 .... Thank you! Getting closer to understand. (The value in the end is a bit "confusing", but I will make some studies and samples.)
@BroCodez
@BroCodez 5 ай бұрын
async/await simplifies the process in the next topic
@jktrivedi29
@jktrivedi29 5 күн бұрын
Wow, after watching many videos finally i understood. Thanks.
@gokhanozdemir8970
@gokhanozdemir8970 2 ай бұрын
Your video made promises clear in my head. Thank you for your effort.
@altlalit
@altlalit 5 ай бұрын
It is the best explanation ever. Thanks
@Eteen12
@Eteen12 2 ай бұрын
This is super helpful, last night was having trouble wrapping my head around this but this video really made it click! Thanks man!
@itzvaibhavkumar3029
@itzvaibhavkumar3029 21 сағат бұрын
Man i love you sm i had such a hard time understanding callbacks and promises
@haidermansoor4760
@haidermansoor4760 4 ай бұрын
The best tutorial on promises. Thanks mannn
@rbsfinger
@rbsfinger 4 ай бұрын
Bro, you rock. Thanks for the video!
@engenheirodesoftware
@engenheirodesoftware 4 ай бұрын
Very good thank you.
@yy.u.i
@yy.u.i 2 ай бұрын
Thank you, it was very clear and simple.
@lambo-ca
@lambo-ca 2 ай бұрын
I finally fully understood. Thanks man.
@mohantraju
@mohantraju 2 ай бұрын
really helpful. Thanks
@bekytadese4466
@bekytadese4466 Ай бұрын
You are great!!!! Thanks a lot
@lillianirungu8180
@lillianirungu8180 18 күн бұрын
Wow thanks a lot. I was struggling to understand but now I do.
@mzedan2
@mzedan2 2 ай бұрын
Thank you very much
@oshadhaedirisinghe1455
@oshadhaedirisinghe1455 Күн бұрын
Thank you
@mr.saiprasad5840
@mr.saiprasad5840 5 ай бұрын
The way of your explain is Awesome #BroCodez Thank You
@ShaileshKumar-re6yz
@ShaileshKumar-re6yz Ай бұрын
Can you please explain the code you wrote inside the then() method. What does it do and why are we creating the arrow function with value parameter and how is it able to access the resolve value
@Jangidlksh1
@Jangidlksh1 Ай бұрын
Yuuuhh, killed it mann
@renatocorreia1805
@renatocorreia1805 4 ай бұрын
THE BEST EXPLANATION
@rajatsachann
@rajatsachann Ай бұрын
Youre a savior man!
@user-sf6ej7cl2t
@user-sf6ej7cl2t 2 ай бұрын
Thank you, it really helped me
@open2003
@open2003 Ай бұрын
You are awesome
@sekwayimokoena3225
@sekwayimokoena3225 4 ай бұрын
The best!
@SuperDude101
@SuperDude101 5 ай бұрын
i just searched about this tomorrow and you uploaded it today what are the odds ;)
@Ershaad-ss3uc
@Ershaad-ss3uc 3 күн бұрын
OO LA LA
@andrewchukwudumeje9413
@andrewchukwudumeje9413 Ай бұрын
If the code is asynchronous why does the first reject prevent the other functions from being executed
@Pururin_Purin
@Pururin_Purin 5 ай бұрын
Honestly I find the "pyramid of doom" less confusing than promises
@pidli
@pidli 3 ай бұрын
😂😂😂😂 same
@jeremyfrias7
@jeremyfrias7 3 ай бұрын
😅 It gets easier with a lot of repetition… It was hard to wrap my head around but just going back over and over and coding along simultaneously can & will do the trick.
@rustyking23able
@rustyking23able 3 ай бұрын
I noticed some tutorials will create a variable equally a new promise kinda like this "var p = new Promise((resolve, reject))" ... in your example you returned promises, is there a preferred way or this situational ?
@user-cup_-nu4kg
@user-cup_-nu4kg 5 ай бұрын
Can you not method chain instead of returning the values of the promises?
@beepboopitsjoop4678
@beepboopitsjoop4678 5 ай бұрын
where was this when i was banging my head against the wall learning this ;.;
@BroCodez
@BroCodez 5 ай бұрын
I was probably still recording it lol
@xXAngelmlXx
@xXAngelmlXx Ай бұрын
I understood it, but you made it a little unclear than it should have. Using .then.then.then without returning anything would've been a little clearer maybe, but there are a few other ways.
@alexidino
@alexidino 2 ай бұрын
how he do this 1:50 ? This little picture ?
@hongquannguyen5532
@hongquannguyen5532 2 ай бұрын
window key + > , for mac is CTRL + CMD + Space
@alexidino
@alexidino 2 ай бұрын
​@@hongquannguyen5532 Thank you, very appreciate !
@abhishekvashistha4017
@abhishekvashistha4017 2 ай бұрын
thanks bud
JavaScript ASYNC/AWAIT is easy! ⏳
4:39
Bro Code
Рет қаралды 48 М.
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 87 М.
Whyyyy? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 19 МЛН
Кәріс өшін алды...| Synyptas 3 | 10 серия
24:51
kak budto
Рет қаралды 1,3 МЛН
1❤️#thankyou #shorts
00:21
あみか部
Рет қаралды 77 МЛН
Edit Text Runs of Rive Animations in Flutter Runtime
5:22
The Motion Magic
Рет қаралды 79
Async JavaScript & Callback Functions -- Tutorial for Beginners
24:21
The Story of Next.js
12:13
uidotdev
Рет қаралды 544 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 283 М.
The JavaScript Survival Guide
14:47
Fireship
Рет қаралды 715 М.
Javascript Promises vs Async Await EXPLAINED (in 5 minutes)
5:50
Roberts Dev Talk
Рет қаралды 545 М.
Whyyyy? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 19 МЛН