@@akshaymarch7 No problem, you truly deserve all the support and encouragement to keep creating such videos for sharing knowledge in such simplest way. And it's not only useful for newcomers, but also for many experienced people like me to strengthen their basics about Javascript. I truly admire your dedication and desperation to make people understand the concept thoroughly. Just keep it up!!
currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
@akshaymarch7 currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
This Episode is a little long, but trust me everything taught is super important. Watch this video with full attention and also finish the homework given at the end of this video. All the Best. Keep Rising! 🚀
If you are really interested to learn or know something really important, then you won't bother about the length of the video. No trash, No Bakwaas, just pure concepts and real-time things. I loved it. Big hug Akshay 🤗.
I had an interview a couple of days back. The interviewer asked me how we can continue executing few "then" blocks even if we have an error from one of them. To be honest, I didn't understand his question then. Now I know what he meant and have the answer after watching this video. Thanks so much Akshay !
1. Promise can be created using a new Promise() constructor function. 2. This constructor function takes a callback function as argument. 3. The callback function has 2 arguments named 'resolve' and 'reject'. Resolve and reject are the keywords provided by JS. 4. We can only resolve or reject a promise. Nothing else can be done. 5. An error can also be created using new Error('error message'). 6. There is also .catch() which is used to attach a failure callback function that handles any error that pops up during the execution of promise chain. 7. .catch only handles error of .then() that are present above it. If there is any .then() below it, catch will not handle any error for that, also that ,then will get executed no matter what. 8. It can be useful in a way if we want to catch error for a particular portion of a chain. 9. We can have multiple catch based on requirement and then a general catch at the end. 10. Always remember to return a value in the promise chain for the next .then to use . 11. If it returns a value => It will be used as an argument in next function. If it is a promise then the next .then in the promise chain is attached to the promise returned by the current callback function. Homework: const cart = ['shoes', 'pants', 'kurta']; createOrder(cart) .then(function(orderId) { console.log(orderId); return orderId; }) .then(function(orderID) { return proceedToPayment(orderID) }) .then(function({ message, amt }) { console.log(message, 'of amount:', amt); return showOrderSummary(message, amt); }) .then(function({ message, amt }) { console.log('Your wallet has beed debited by:', amt); }) .catch(function(err) { console.log(err.message); }) .then(function() { console.log('No matter what happens, I will get executed'); }); function createOrder(cart) { const pr = new Promise(function(resolve, reject) { // create order // Validate Cart // orderId if (!validateCart(cart)) { const err = new Error('Cart is not valid!'); reject(err); } // logic for createOrder const orderId = '12345'; if (orderId) { setTimeout(function() { resolve(orderId); }, 5000) } }); return pr; } function proceedToPayment(orderID) { // Logic for handling payment. // This function returns a promise return new Promise(function(resolve, reject) { // logic resolve({ message: `Payment Successful for order id: ${orderID}`, amt: 2500 }); }) } function showOrderSummary(paymentInfo, amt) { return new Promise(function(resolve, reject) { // console.log(amt); if (amt >= 2000) { resolve({ message: 'You have ordered items that cost ${amt} RS', amt }); } else { reject(new Error('Please buy more for discount')); } }) } function validateCart(cart) { // code to validate cart. return true; // return false; }
Akshay just want to say a big thank you. i have been working for over 10 years in IT industry but the clarity of javascript given by you for core concepts is invaluable. Not only it helped me in interviews but also helped to be a better developer. Amazing work!!! I hope you'll amaze us every time and keep the good content coming :)
Nowadays everyone is creating for beginners or a so called crash course but.... As developer I want to see such kind of videos where you will see deep scenario and realtime code debugging we like this length of videos Kudos to you Akshay bhaiya❤️
Thanks Akshay for distilling JavaScript into your super easy videos. I just loved it. You're giving your precious time to teach all of us here, Kudos to you. Looking forward to your next awesome video.
@Ranjan - Why did you pay for the school where you studied ! It is available free does not mean there are no efforts given. It might be his kindness that he gave it for free. But at the same I felt that he might need to setup and what not other expenses for all these sessions. Hence I paid and believe me the money I paid is just a way of thanking him and his efforts ! Not a necessity. I hope i was able to answer your doubt !
I fall in love with promises just because of you thank you so much sirr.......... you are best....... i was promiseFobia but just because of you it gone.......... thank you so much agai for making me jorney easy.... you are the best...... i always sleepy when i am doing lecture but just because of you I just addicted to javascript like web series........ after getting job i will definitely contrubute you........... thank you so muchhh..............!❤❤
Oh, I'm very excited because I got heart react from Akshay Sir😃. I thought that the series is old and Akshay bhai is no longer seeking comment. But you read my comment. I hope you also check this commend as well and I want to say that. I'm your big fan sir!!! Amazing skill and explanation. You are wonderfull. Lot of love from my side Akshay bhai. Just superb smile and attitude. God bless you and your family more and more.💝🥰😍
Excellent videos! Thank you. Please produce more like these, I love how you simplify things and make everything make sense and don't worry about the length! Serious learners will sit through hours of video if the content is high quality like this!
Best Video explaining Promise on the entire internet. Please keep making such in depth videos no matter how long they are. Love the way you explain things from ground level and build on top of that. Thank you so much Sir.
Thank you so much Akshay for such amazing learning content❤ I invested in Namaste React course in the end of last year, currently learning new in depth about React. And I am very excited for your future Namaste System Design course and DSA course too. Feel soo good to invest in such amazing courses for growth. ❤
Hi Akshay, people like me are really loving these content of javascript and the way you are teaching has made all of us love Javascript. Please please please release the next episodes ...We all love your content, your efforts, your teaching style.
I really like lengthy videos if they are actually going deep into the concepts like you. So please continue doing this and please again start off this season. I am waiting for the other topics
Note:- you can complete this video in just 2 min by reading this comment but please must watch the video. In this video you will learn about promise chaining and error handing very deeply you will see how you can overcome the problem of callback hell (Pyramid of doom) while the time of using promise you can trust that promise it will call once surely and it has two possible state it can we resolve or reject, to handle promise reject state you can place a catch method at the end of the promise chaining it will handle all the rejected promise and give some output you also can place catch method for a specific line of code in promise chaining to handle fall of code. THANKYOU AKSHAY BHAIYA FOR EVERYTHING❤
A couple of things which could be added to the video(maybe in the next) : 1) "Catch" is not just for the method like createOrder rejecting things but any error which can occur within the then's callback as well. 2) "then" takes two callbacks for resolved and rejected case, even though that's not a pattern we Devs generally follow and because it's not handled it gets passed down to "catch" . 👍
Your Teaching very well !!! as student with curiosity i want to know every thing , why things happing , what going in the bg when i ran my code , u explain each and every thing along with industries problem that we have to face in the future , you are the best coding teacher i ever found on internet .
Hi Akshay, thank you so very much on JS. You won't believe. U achieved ur target of making viewers fall in love with JS. Yes, I already fell in love with JS. All credit goes to you. Thank you once again!! Have you created any video on arrow functions?? If not, can you please create one?? Just want to know its practical importance and how and where it becomes better/advantageous than normal functions in javascript. There are many videos on it but nothing explains from the root of concepts like you?? Thanks in advance!!
I have completed Season 2 just now in one day. I am a very choosy person if I didn't understand in the first 10 minutes then I will skip that video. BUT TRUST ME I started at 1:30 PM and continuously watched till 5 PM. I get a lot of knowledge from you. YOu helped in clearing my doubts. Now I am going to write the blog. ThankYOu Once Again. Please Post next video soon
I though functions were only beautiful. However, after going through promise episodes I realise promises are also beautiful. Thank you so much for making us fall in love with Javascript 🙏
You're a great Teacher Akshay. Nowadays whenever I watch a new video of yours I assume I will be surprised, and I am not even disappointed once. Frankly speaking I would have slept if someone else would have made video this long. But I can watch all your episodes in one go, due to the unique content and your unique way of Teaching. Thankyou for all your efforts and hoping to see the new video soon :)
I see that this comment is also placed on others people's comment too, could you please explain us? Or where is it the link to be redirected to you telegram?
Hello Sir ! These two promises video made my concept regarding promises very clear. When are the further videos in this series coming. We are waiting for new things to learn from you
great explanation, The Best part that every RUclips teacher should add to their videos is homework as this videos homework, Thanks for creating such great tutorials
We really like your videos. I watched a lot of videos before to understand promise but I only got confused. After watching your video, now this promise concept is crystal clear to me. Please don't stop uploading videos.
where is the next part of this videos it's into this playlist. if u have already made that video then plz update this playlist else made that video plz . And also try to make some videos on the frontend project . that would be very helpful .. Tqs for such content......
Please don't reduce video length. We need these dive deeper kinda videos otherwise there are tons of videos available on youtube explaining promises in just 5-10 mins.
Thank you Akshay, you clarified my mind, I really had a lot of confuses before. But u put everything in order and gave clear understanding! I appreciate it and I'll share all of ur videos with my friends, cause your tutorials are really best❤👏👏👏
akshay your amazing there no words enough to thank you. each and every episodes of java script I fallen in love in js . now im very confident to use js. thank you very much aksay😄
i am from non IT background and i want shift my career toward tech , i am learning javascript and others language from last 5 months i watched lots of videos regarding to promise but not clear the concept my friend suggested your videos , finally now clear my doubt regarding promise 👍👍👍👍
@akshaymarch7 you are really a good teacher. JavaScript was like a monster I was trying to fight against and conquer, but unfortunately, couldn't learn how to. But you explained the concepts so clearly that I can built something using JS. Thanks Thanks Thanks buddy.
completed season 1 and season 2 till episode 3, Iam much confident in javascript now .Thankyou very much for putting this excellent content for free , and bruh you look somehwhat like ravindra jadeja..... 😅😅
Bro you are truly legend...you made me fall in love with JavaScript 😂... keep teaching us...lots of respect for you... length is not a matter until unless it has a content..... 🙏✌
It's really great to have a youtube video that explaines all these important concept in such depth. It's really like going to a lecture at university. Such a great content!
Don't think about length of the video.. just make videos like this so that we don't have to watch any other video to understand more related to the topic ❤️❤️❤️ Thank you so much for the season 2❤️❤️❤️❤️
Making lengthy videos is not a problem at all and thanks for making this video. This is the most important concept in JavaScript. I hope you will cover async and await also 😍 in future.
These are lengthy videos but are totally worth it. Please keep making similar videos. Don't worry about the length of the video. Just keep doing the good work Akshay. Promise is a very confusing topic, and you are making it very easy. Please make more videos on promises.
Excellent stuff, Thanks Akshay!
Thank you so much for supporting my channel, Sujit. This means a lot. ❤️
@@akshaymarch7 No problem, you truly deserve all the support and encouragement to keep creating such videos for sharing knowledge in such simplest way.
And it's not only useful for newcomers, but also for many experienced people like me to strengthen their basics about Javascript.
I truly admire your dedication and desperation to make people understand the concept thoroughly.
Just keep it up!!
I like to pay but I don't have any money
Sorry for taking stuff free
currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
@akshaymarch7 currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
This Episode is a little long, but trust me everything taught is super important. Watch this video with full attention and also finish the homework given at the end of this video. All the Best. Keep Rising! 🚀
always
I'm watching this video over and over again... It's so addictive.
Akshay sir, Please make a vedio on polyfill concepts...🙏🙏
akshay sir, you didn't upload any more videos ? everything is good ?
Hi Akshay, when can we expect video on Async await and how it is better than promise chaining.. ?
If you are really interested to learn or know something really important, then you won't bother about the length of the video. No trash, No Bakwaas, just pure concepts and real-time things. I loved it. Big hug Akshay 🤗.
Thank you so much for supporting my channel, Abhishek. This means a lot. ❤️
Bhai...! Kya hi bolu main aapko! Just take my 🙏Namaskar🙏
You don't know how many problems of developers you've solved just by this video.
Most beautiful playlists on JavaScript.
Binge watched the 23+4=27 videos in 3 days.
*Please continue this series.*
Akshay you are great...you made me fall in love with JavaScript 😂... keep teaching us...lots of respect for you
I had an interview a couple of days back. The interviewer asked me how we can continue executing few "then" blocks even if we have an error from one of them. To be honest, I didn't understand his question then. Now I know what he meant and have the answer after watching this video. Thanks so much Akshay !
1. Promise can be created using a new Promise() constructor function.
2. This constructor function takes a callback function as argument.
3. The callback function has 2 arguments named 'resolve' and 'reject'. Resolve and reject are the keywords provided by JS.
4. We can only resolve or reject a promise. Nothing else can be done.
5. An error can also be created using new Error('error message').
6. There is also .catch() which is used to attach a failure callback function that handles any error that pops up during the execution of promise chain.
7. .catch only handles error of .then() that are present above it. If there is any .then() below it, catch will not handle any error for that, also that ,then will get executed no matter what.
8. It can be useful in a way if we want to catch error for a particular portion of a chain.
9. We can have multiple catch based on requirement and then a general catch at the end.
10. Always remember to return a value in the promise chain for the next .then to use .
11. If it returns a value => It will be used as an argument in next function. If it is a promise then the next .then in the promise chain is attached to the promise returned by the current callback function.
Homework:
const cart = ['shoes', 'pants', 'kurta'];
createOrder(cart)
.then(function(orderId) {
console.log(orderId);
return orderId;
})
.then(function(orderID) {
return proceedToPayment(orderID)
})
.then(function({ message, amt }) {
console.log(message, 'of amount:', amt);
return showOrderSummary(message, amt);
})
.then(function({ message, amt }) {
console.log('Your wallet has beed debited by:', amt);
})
.catch(function(err) {
console.log(err.message);
})
.then(function() {
console.log('No matter what happens, I will get executed');
});
function createOrder(cart) {
const pr = new Promise(function(resolve, reject) {
// create order
// Validate Cart
// orderId
if (!validateCart(cart)) {
const err = new Error('Cart is not valid!');
reject(err);
}
// logic for createOrder
const orderId = '12345';
if (orderId) {
setTimeout(function() {
resolve(orderId);
}, 5000)
}
});
return pr;
}
function proceedToPayment(orderID) {
// Logic for handling payment.
// This function returns a promise
return new Promise(function(resolve, reject) {
// logic
resolve({ message: `Payment Successful for order id: ${orderID}`, amt: 2500 });
})
}
function showOrderSummary(paymentInfo, amt) {
return new Promise(function(resolve, reject) {
// console.log(amt);
if (amt >= 2000) {
resolve({ message: 'You have ordered items that cost ${amt} RS', amt });
} else {
reject(new Error('Please buy more for discount'));
}
})
}
function validateCart(cart) {
// code to validate cart.
return true;
// return false;
}
Thanks brother 🙏
Bhai mai namaste javascript wali hrr ek video k comment section m tumko dhoondhta hu, video khatam hona k baad
@@python-gamer9711 His name is reflect is work... isin' tit. 😊
Bhai aapka knowledge toh kamaal ka hai bhai.
@@harshmohite6297 sahi baat hai
Big Thanks to Akshay sir
Pls bring the EP04, waiting for it.
Ha Bhai daalo age k videos yaar jaldi jaldi
Thank you so much for supporting my channel. This means a lot. ❤️
Akshay just want to say a big thank you. i have been working for over 10 years in IT industry but the clarity of javascript given by you for core concepts is invaluable. Not only it helped me in interviews but also helped to be a better developer. Amazing work!!!
I hope you'll amaze us every time and keep the good content coming :)
Nowadays everyone is creating for beginners or a so called crash course but.... As developer I want to see such kind of videos where you will see deep scenario and realtime code debugging we like this length of videos Kudos to you Akshay bhaiya❤️
bhai tu developer bna kaise fir
@@himanshuarora1910 after creating to do list
It is only a joke!
when can we expect EP-04 ???
you made me fall in love with JavaScript, Amazing content
fr it made me fall in love too
It's here😍. For the first time in my life, I'm excited that a video is long, because I know I'll definitely get more quality content.
Thanks Akshay for distilling JavaScript into your super easy videos. I just loved it. You're giving your precious time to teach all of us here, Kudos to you. Looking forward to your next awesome video.
Thank you so much for supporting my channel, Manohar. This means a lot. ❤️
@@akshaymarch7 bro when can we expect the next video
I binge-watched your JS series; Thank you for all the "Aha!" Moments. You are Pushpa and JS is Red-sanders; Thagede Le!
My solution to the problem:
const cart = ["Bitcoin", "Glasses", "Kurta", "Jacob & Co", "Xbox"]
let order
createOrder(cart)
.then(function (orderId) {
order = orderId
return proccedToPayment(orderId)
})
.then(function (pin) {
return showOrderSummary(pin)
})
.then(function (msg) {
updateWallet(order, msg)
})
.catch((err) => {
console.log(err)
})
function createOrder(items) {
return new Promise((reslove, reject) => {
if (items.length >= 5) {
console.log("Order: 49591214")
reslove(49591214)
} else {
const err = new Error("Add more Items. Items must be >=5")
reject(err)
}
})
}
function proccedToPayment(orderId) {
return new Promise((reslove, reject) => {
setTimeout(() => {
if (orderId === 49591214) {
console.log("OrderID: 49591214 Enter your UPI Pin")
const pin = 13579
reslove(pin)
} else {
const err = new Error("Payment not succesful")
reject(err)
}
}, 5000)
})
}
function showOrderSummary(pin) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (pin === 135790) {
resolve("Payment Succesful! Order Created: ")
} else {
const err = new Error("WRONG PIN!")
reject(err)
}
}, 4000)
})
}
function updateWallet(order, msg) {
console.log(msg + order)
}
Thank you so much for supporting my channel. This means a lot. ❤️
This is the bestesttt JS course I have found on internet. Please just do not stop this course. That's all we wish for 🙏.
Bing watched both seasons in 2 days.. nd a big big thanks from bottom of my heart.. thanku sir ✨️
Your videos helped me in cracking an interview
Thank you so much for supporting my channel. This means a lot. ❤️
Thanks a lot for all your awesome videos. I know and respect each and every efforts behind each video !
Thank you so much for supporting my channel, Ganesh. This means a lot. ❤️
Hi Ganesh. Y are u paying money to Akshay?
@Ranjan - Why did you pay for the school where you studied !
It is available free does not mean there are no efforts given. It might be his kindness that he gave it for free. But at the same I felt that he might need to setup and what not other expenses for all these sessions. Hence I paid and believe me the money I paid is just a way of thanking him and his efforts !
Not a necessity. I hope i was able to answer your doubt !
@@ganeshkhirwadkar4127 that's great initiative from your side. I will also pay.
Thanks for your ans👍☺️
well answered@@ganeshkhirwadkar4127
I fall in love with promises just because of you thank you so much sirr.......... you are best....... i was promiseFobia but just because of you it gone.......... thank you so much agai for making me jorney easy.... you are the best...... i always sleepy when i am doing lecture but just because of you I just addicted to javascript like web series........ after getting job i will definitely contrubute you........... thank you so muchhh..............!❤❤
The best part of your all videos is "Your smile at end" 😃😅 Tremendous
Oh, I'm very excited because I got heart react from Akshay Sir😃. I thought that the series is old and Akshay bhai is no longer seeking comment. But you read my comment. I hope you also check this commend as well and I want to say that. I'm your big fan sir!!! Amazing skill and explanation. You are wonderfull. Lot of love from my side Akshay bhai. Just superb smile and attitude. God bless you and your family more and more.💝🥰😍
Totally... the happiness we all resonate with :)
Mera bhai, mera dost, mera guru best youtuber for javascript with deep knowledge come back ab koi ni tikega javascript content m because of you.
Akshay big thanks to you for make such kind of videos. I really appreciate your teaching technique for deep concepts.
const cart = [
{
itemName : 'Shoes',
itemPrice : 2000
},
{
itemName : 'Paint',
itemPrice : 2500
},
{
itemName : 'Kurta',
itemPrice : 1500
}
];
let walletBalance = 10000;
createOrder(cart)
.then(function(orderId){
return orderId;
})
.then(function(orderId){
return proceedToPayment(orderId);
})
.then(function(orderStatus){
return showOrderSummery(orderStatus);
})
.then(function(orderHistory){
return updateWallet(orderHistory);
})
.then(function(res){
console.log(res);
})
.catch((err)=>{
console.log(err.message)
})
function createOrder(cart){
return new Promise(function(resolve,reject){
if(!validateCart(cart)){
reject(new Error("Cart is not valid"));
}
let orderId=10
if(orderId){
resolve(orderId);
}
})
}
function proceedToPayment(orderId){
return new Promise(function(resolve,reject){
if(orderId){
resolve({paymentStatus : 1, message : "Payment successfully completed"});
}else{
reject(new Error("Payment Failed"));
}
})
}
function showOrderSummery(orderStatus){
return new Promise(function(resolve,reject){
if(orderStatus.paymentStatus === 1){
resolve({status:'success', orders : cart});
}else{
reject(new Error("Something went wrong"));
}
})
}
function updateWallet(orderHistory){
return new Promise(function(resolve,reject){
if(orderHistory.status === 'success'){
let orderAmount = 6000;
walletBalance = walletBalance - orderAmount;
resolve({balance : walletBalance, 'message':'Wallet updated'});
}else{
reject(new Error("Wallet balance not updated"));
}
})
}
function validateCart(cart){
return true;
}
If any kind of suggestion for my code please tell me.✍
createOrder(cart)
.then(orderId => orderId)
.then(orderId => proceedToPayment(orderId))
.then(orderStatus => showOrderSummery(orderStatus))
.then(orderHistory => updateWallet(orderHistory))
.then(res => console.log(res))
.catch(err => console.log(err.message))
Nicely written bro
Awesome bro @omprakashmaurya
Same solution with async/await
async function getOrderDetails() {
const orderId = await createOrder(cart)
console.log(orderId)
const orderStatus = await proceedToPayment(orderId)
const orderHistory = await showOrderSummary(orderStatus)
const response = await updateWallet(orderHistory)
const finalResult = await (function(){
return response
}(response))
console.log(finalResult)
}
getOrderDetails()
@@senthamarai_kannan. You should return the parameters like order Id and proceedToPayment and all
Excellent videos! Thank you. Please produce more like these, I love how you simplify things and make everything make sense and don't worry about the length! Serious learners will sit through hours of video if the content is high quality like this!
Best Video explaining Promise on the entire internet. Please keep making such in depth videos no matter how long they are. Love the way you explain things from ground level and build on top of that. Thank you so much Sir.
Now onwards it's super easy to keep promises in mind.😅
Thanks for this amazing content.😇
Thank you so much for supporting my channel, Pratyush. This means a lot. Happy Diwali ❤️
Happy Diwali 🎇🎇
Please continue with this series need this series to be watched by millions of user
Thank you so much Akshay for such amazing learning content❤
I invested in Namaste React course in the end of last year, currently learning new in depth about React.
And I am very excited for your future Namaste System Design course and DSA course too. Feel soo good to invest in such amazing courses for growth. ❤
Hi Akshay, people like me are really loving these content of javascript and the way you are teaching has made all of us love Javascript. Please please please release the next episodes ...We all love your content, your efforts, your teaching style.
Your playlist helped me a lot in my career.
Thanks Akshay
Thank you so much Pavan, this means a lot! ♥️
Your are great teacher my life is changed after watching namaste javascript and my confidence level boost towards coding.
Consistency at it's best❤️
Thank you so much for supporting my channel, Pravin. This means a lot. ❤️
@@akshaymarch7 please make a video on arrow function
Just blown away when you said what happens when we just reject and do not handle errors.
first like and first comment
respect from egypt 🇪🇬
Ali
I really like lengthy videos if they are actually going deep into the concepts like you. So please continue doing this and please again start off this season. I am waiting for the other topics
Big thanks for teaching us the very important Promise concept. Here is the homework code:-
const cart = [
{
itemName: "Jeans",
itemPrice:4000
},
{
itemName: "Shoes",
itemPrice:8000
},
{
itemName: "Socks",
itemPrice:400
},
{
itemName: "Purse",
itemPrice:1500
}
];
let balance = 20000;
createOrder(cart)
.then(function(orderID){
return orderID;
})
.then(function (orderID) {
return proceedToPayment(orderID);
})
.then(function (paymentInfo) {
return showOrderSummary(paymentInfo);
})
.then(function (balance) {
return updateWallet(balance);
})
.then(function (resBalance) {
console.log(resBalance.balance);
})
.catch(function err() {
console.log(err.message);
})
function createOrder(cart) {
const pr = new Promise(function (resolve, reject) {
if(!validateCart){
const err = new Error("Card is not valid");
reject(err);
}
const orderID = "897650";
if(orderID){
setTimeout(function () {
resolve(orderID);
}, 5000);
}
});
return pr;
}
function proceedToPayment(orderID) {
return new Promise(function (resolve, reject) {
if(orderID){
resolve({
paymentStatus: true,
message: "Payment Successful!"
});
}
else{
reject(new Error("Payment failed!"));
}
})
}
function showOrderSummary(paymentInfo) {
return new Promise(function (resolve, reject) {
if(paymentInfo.paymentStatus){
resolve({
status: "success",
order: "cart"
})
}
else{
reject(new Error("Something went wrong!"));
}
})
}
function updateWallet(history) {
return new Promise(function (resolve, reject) {
if(history){
if(history.status == "success"){
let amount = 5000;
balance = balance - amount;
resolve({
balance: balance,
message:"Updated Balance"
});
}
}
else{
reject(new Error("Wallet not updated!"));
}
})
}
function validateCart(cart) {
return true;
}
Bhai mujhe ek problem hey
Mujhe code smjh aa jata hey lekin khud se likh nhi pata hu😢
Kuch usefull tips dedo
@@mseditx1334 start with simple code and do practice
don't jump to direct large code
Note:- you can complete this video in just 2 min by reading this comment but please must watch the video.
In this video you will learn about promise chaining and error handing very deeply you will see how you can overcome the problem of callback hell (Pyramid of doom) while the time of using promise you can trust that promise it will call once surely and it has two possible state it can we resolve or reject, to handle promise reject state you can place a catch method at the end of the promise chaining it will handle all the rejected promise and give some output you also can place catch method for a specific line of code in promise chaining to handle fall of code.
THANKYOU AKSHAY BHAIYA FOR EVERYTHING❤
A couple of things which could be added to the video(maybe in the next) : 1) "Catch" is not just for the method like createOrder rejecting things but any error which can occur within the then's callback as well. 2) "then" takes two callbacks for resolved and rejected case, even though that's not a pattern we Devs generally follow and because it's not handled it gets passed down to "catch" . 👍
Your Teaching very well !!! as student with curiosity i want to know every thing , why things happing , what going in the bg when i ran my code , u explain each and every thing along with industries problem that we have to face in the future , you are the best coding teacher i ever found on internet .
Hi Akshay, thank you so very much on JS. You won't believe. U achieved ur target of making viewers fall in love with JS. Yes, I already fell in love with JS. All credit goes to you. Thank you once again!! Have you created any video on arrow functions?? If not, can you please create one?? Just want to know its practical importance and how and where it becomes better/advantageous than normal functions in javascript. There are many videos on it but nothing explains from the root of concepts like you?? Thanks in advance!!
I am a react developer ,For any interview I just go through your videos and I overcome many interviews.
OHH my God am in love with your teaching, even as a person with 3+ years experience, I respect your level of explanation.
I have completed Season 2 just now in one day. I am a very choosy person if I didn't understand in the first 10 minutes then I will skip that video. BUT TRUST ME I started at 1:30 PM and continuously watched till 5 PM. I get a lot of knowledge from you. YOu helped in clearing my doubts. Now I am going to write the blog. ThankYOu Once Again. Please Post next video soon
The way you explain the concepts is awesome. If you can also create videos on oops and solid principals, it would be very useful.
Lengthy videos are never an issue Akshay sir, getting the knowledge about each n everything in depth is what matters!
waiting for episode 4, hope you will make it fast.🥰🥰
No vedios
35:35 to 39:01 you promised i believed. Maatu maatagirbeku❤️
No words :) Just amazing you made the promise so easy to understand waiting for more such content 😎🔥🚀
@Akshay saini sir i think you need to look into this looks scam to me 🤔
@@abhishekvishwakarma9045 yeahhhhhh many comments have this reply
bahut ache se explain kiya hai . kahin aur se padhne ki jarurat hi nhi
I though functions were only beautiful. However, after going through promise episodes I realise promises are also beautiful. Thank you so much for making us fall in love with Javascript 🙏
Thanks!
Thank you so much for supporting my channel, John. This means a lot. ❤️
You're a great Teacher Akshay. Nowadays whenever I watch a new video of yours I assume I will be surprised, and I am not even disappointed once. Frankly speaking I would have slept if someone else would have made video this long. But I can watch all your episodes in one go, due to the unique content and your unique way of Teaching. Thankyou for all your efforts and hoping to see the new video soon :)
Thanks
Thank you so much for supporting my channel, Sandeep. This means a lot. ❤️
THANKKKKK YOUUUUUUU, THE BEST SURPRISE, 2 VIDEOS IN A WEEK YEAHHHH
I don't understand hahaha, am I the winner? Where do I text you, I'm impressed
I see that this comment is also placed on others people's comment too, could you please explain us? Or where is it the link to be redirected to you telegram?
Hello Sir ! These two promises video made my concept regarding promises very clear. When are the further videos in this series coming. We are waiting for new things to learn from you
great explanation, The Best part that every RUclips teacher should add to their videos is homework as this videos homework, Thanks for creating such great tutorials
Thanks Akshay...
Thank you so much for supporting my channel, Vipul. This means a lot. ❤️
Akshay, I am astounded by the quality of your content! I will be eternally grateful for your content.
Bro start teaching REACTJS. Your really great inspiration for me.
Akshay you are real champion of JavaScript... Thankyou..
Please keep teaching us...
And upload one video daily
Its a great content Akshay! We definitely want to dive deep through examples. Its ok if videos are getting longer as the content is real gold
We really like your videos. I watched a lot of videos before to understand promise but I only got confused. After watching your video, now this promise concept is crystal clear to me. Please don't stop uploading videos.
Like all your videos, it's excellent. I look forward to the ASYNC/AWAY theme. I hope you also consider the topic of GENERATORS.
What a Quality content yaar. All of my doubt cleared in a single video
We just love ashkay as we love javascript literally Big thanks to you man
where is the next part of this videos it's into this playlist. if u have already made that video then plz update this playlist else made that video plz . And also try to make some videos on the frontend project . that would be very helpful .. Tqs for such content......
Length of video is not a problem at all, we would love to hear you hours together with such lovely content.
Please don't reduce video length. We need these dive deeper kinda videos otherwise there are tons of videos available on youtube explaining promises in just 5-10 mins.
I've a test tomorrow and JS is in the syllabus and here is your video that'll help me
Grateful
No, this is good length video, explaining everything in detail. Thank you for this!!!
Your videos should be at least 1 hour long.....they teaches us a lot, Take love from Pakistan 🇵🇰❤️🇮🇳
Better than some premium courses out there in the market.
Thank you Akshay, you clarified my mind, I really had a lot of confuses before. But u put everything in order and gave clear understanding! I appreciate it and I'll share all of ur videos with my friends, cause your tutorials are really best❤👏👏👏
akshay your amazing there no words enough to thank you. each and every episodes of java script I fallen in love in js . now im very confident to use js. thank you very much aksay😄
i am from non IT background and i want shift my career toward tech , i am learning javascript and others language from last 5 months
i watched lots of videos regarding to promise but not clear the concept my friend suggested your videos ,
finally now clear my doubt regarding promise
👍👍👍👍
@akshaymarch7 you are really a good teacher. JavaScript was like a monster I was trying to fight against and conquer, but unfortunately, couldn't learn how to. But you explained the concepts so clearly that I can built something using JS. Thanks Thanks Thanks buddy.
Promise us to Teach forever 😍 🔥
completed season 1 and season 2 till episode 3, Iam much confident in javascript now .Thankyou very much for putting this excellent content for free , and bruh you look somehwhat like ravindra jadeja..... 😅😅
The best explanation on promises ever!
What a gem of a person you are. The amount of clarity you have is phenomenal
Bro you are truly legend...you made me fall in love with JavaScript 😂... keep teaching us...lots of respect for you... length is not a matter until unless it has a content..... 🙏✌
It's really great to have a youtube video that explaines all these important concept in such depth. It's really like going to a lecture at university. Such a great content!
continue with detailed video like these ...it will get better reach
and thanks for clear explanation.
Fall in love with your way of teaching.
Perfect concepts with perfect length of the video.
Don't think about length of the video.. just make videos like this so that we don't have to watch any other video to understand more related to the topic ❤️❤️❤️
Thank you so much for the season 2❤️❤️❤️❤️
beyond words!! this is the best promise chaining video on internet!!! thanks buddy!
I love the way you explain things.
Thank you making javascript a piece of cake.
May God bless you.
I crack a job of 125% hype by just watching videos thank you so much sir love you a lot ❤
Which company and what frame work?
Please bring the next videos as soon as possible we are just loving this series.
Making lengthy videos is not a problem at all and thanks for making this video.
This is the most important concept in JavaScript. I hope you will cover async and await also 😍 in future.
you are very good teacher so far on youtube.
I've watched all season 1 video and watching season 2 as well.
ground m jaddu bhai kamal krte h or ynha aap both are ❤️❤️❤️❤️
bhai gajab ase hi video cahiye jo deep me ho maja aa gaya
Finally I really like you are uploading videos consistently. THANK YOU SO MUCH BRO
you are legend in JavaScript world
These are lengthy videos but are totally worth it. Please keep making similar videos. Don't worry about the length of the video. Just keep doing the good work Akshay. Promise is a very confusing topic, and you are making it very easy. Please make more videos on promises.
Please add more videos thank you so much for these content! Can't have it enough of them!
Brother Litterally Love u I could'nt Find Anyone Except you to explain things in this style solute u bro 💕💕
Solved all my doubts related to Promises. Thanks a lot. Keep up the good work.