What are JavaScript PROMISES? 🤞

  Рет қаралды 32,141

Bro Code

Bro Code

4 ай бұрын

#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

Пікірлер: 37
@BroCodez
@BroCodez 4 ай бұрын
// 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 4 ай бұрын
Finally, I understand PROMISES. Thanks
@SaintHanappi
@SaintHanappi 4 ай бұрын
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 4 ай бұрын
async/await simplifies the process in the next topic
@altlalit
@altlalit 4 ай бұрын
It is the best explanation ever. Thanks
@gokhanozdemir8970
@gokhanozdemir8970 Ай бұрын
Your video made promises clear in my head. Thank you for your effort.
@Eteen12
@Eteen12 Ай бұрын
This is super helpful, last night was having trouble wrapping my head around this but this video really made it click! Thanks man!
@rbsfinger
@rbsfinger 3 ай бұрын
Bro, you rock. Thanks for the video!
@haidermansoor4760
@haidermansoor4760 3 ай бұрын
The best tutorial on promises. Thanks mannn
@engenheirodesoftware
@engenheirodesoftware 3 ай бұрын
Very good thank you.
@bekytadese4466
@bekytadese4466 26 күн бұрын
You are great!!!! Thanks a lot
@lambo-ca
@lambo-ca Ай бұрын
I finally fully understood. Thanks man.
@mohantraju
@mohantraju Ай бұрын
really helpful. Thanks
@renatocorreia1805
@renatocorreia1805 3 ай бұрын
THE BEST EXPLANATION
@yy.u.i
@yy.u.i Ай бұрын
Thank you, it was very clear and simple.
@rajatsachann
@rajatsachann 17 күн бұрын
Youre a savior man!
@open2003
@open2003 21 күн бұрын
You are awesome
@mr.saiprasad5840
@mr.saiprasad5840 4 ай бұрын
The way of your explain is Awesome #BroCodez Thank You
@user-sf6ej7cl2t
@user-sf6ej7cl2t Ай бұрын
Thank you, it really helped me
@mzedan2
@mzedan2 Ай бұрын
Thank you very much
@SuperDude101
@SuperDude101 4 ай бұрын
i just searched about this tomorrow and you uploaded it today what are the odds ;)
@sekwayimokoena3225
@sekwayimokoena3225 3 ай бұрын
The best!
@ShaileshKumar-re6yz
@ShaileshKumar-re6yz 9 күн бұрын
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
@user-cup_-nu4kg
@user-cup_-nu4kg 4 ай бұрын
Can you not method chain instead of returning the values of the promises?
@Pururin_Purin
@Pururin_Purin 4 ай бұрын
Honestly I find the "pyramid of doom" less confusing than promises
@pidli
@pidli 2 ай бұрын
😂😂😂😂 same
@jeremyfrias7
@jeremyfrias7 2 ай бұрын
😅 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.
@andrewchukwudumeje9413
@andrewchukwudumeje9413 6 күн бұрын
If the code is asynchronous why does the first reject prevent the other functions from being executed
@rustyking23able
@rustyking23able 2 ай бұрын
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 ?
@xXAngelmlXx
@xXAngelmlXx 5 күн бұрын
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.
@beepboopitsjoop4678
@beepboopitsjoop4678 4 ай бұрын
where was this when i was banging my head against the wall learning this ;.;
@BroCodez
@BroCodez 4 ай бұрын
I was probably still recording it lol
@alexidino
@alexidino Ай бұрын
how he do this 1:50 ? This little picture ?
@hongquannguyen5532
@hongquannguyen5532 Ай бұрын
window key + > , for mac is CTRL + CMD + Space
@alexidino
@alexidino Ай бұрын
​@@hongquannguyen5532 Thank you, very appreciate !
@abhishekvashistha4017
@abhishekvashistha4017 Ай бұрын
thanks bud
JavaScript ASYNC/AWAIT is easy! ⏳
4:39
Bro Code
Рет қаралды 38 М.
JavaScript Promises  -- Tutorial for Beginners
37:05
ColorCode
Рет қаралды 102 М.
Кәріс тіріма өзі ?  | Synyptas 3 | 8 серия
24:47
kak budto
Рет қаралды 1,6 МЛН
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 6 МЛН
The magical amulet of the cross! #clown #小丑 #shorts
00:54
好人小丑
Рет қаралды 21 МЛН
小路飞姐姐居然让路飞小路飞都消失了#海贼王  #路飞
00:47
路飞与唐舞桐
Рет қаралды 42 МЛН
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 71 М.
Async JS Crash Course - Callbacks, Promises, Async Await
24:31
Traversy Media
Рет қаралды 1,4 МЛН
Learn JSON files in 10 minutes! 📄
10:09
Bro Code
Рет қаралды 28 М.
5 Uncommon Python Features I Love
15:09
Indently
Рет қаралды 118 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
All The JavaScript You Need To Know For React
28:00
PedroTech
Рет қаралды 532 М.
GPT-4o Deep Dive: the AI that CRUSHES everything
28:11
AI Search
Рет қаралды 44 М.
3 Bad Python Habits To Avoid
10:40
Indently
Рет қаралды 43 М.
Кәріс тіріма өзі ?  | Synyptas 3 | 8 серия
24:47
kak budto
Рет қаралды 1,6 МЛН