Creating a Promise, Chaining & Error Handling | Ep 03 Season 02 Namaste JavaScript

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 988

  • @sujit510
    @sujit510 Год назад +182

    Excellent stuff, Thanks Akshay!

    • @akshaymarch7
      @akshaymarch7  Год назад +27

      Thank you so much for supporting my channel, Sujit. This means a lot. ❤️

    • @sujit510
      @sujit510 Год назад +14

      @@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!!

    • @asishankam6552
      @asishankam6552 Год назад +11

      I like to pay but I don't have any money
      Sorry for taking stuff free

    • @ayushi8412
      @ayushi8412 Год назад +2

      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?

    • @ayushi8412
      @ayushi8412 Год назад

      @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?

  • @akshaymarch7
    @akshaymarch7  2 года назад +237

    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! 🚀

    • @EngineBoy
      @EngineBoy Год назад +2

      always

    • @mayukhdevansahu5707
      @mayukhdevansahu5707 Год назад +2

      I'm watching this video over and over again... It's so addictive.

    • @dakshlakhotiya4275
      @dakshlakhotiya4275 Год назад

      Akshay sir, Please make a vedio on polyfill concepts...🙏🙏

    • @yogeshkataria9741
      @yogeshkataria9741 Год назад +4

      akshay sir, you didn't upload any more videos ? everything is good ?

    • @AbhishekPal-666
      @AbhishekPal-666 Год назад

      Hi Akshay, when can we expect video on Async await and how it is better than promise chaining.. ?

  • @spillthebuzz
    @spillthebuzz Год назад +114

    when can we expect EP-04 ???
    you made me fall in love with JavaScript, Amazing content

  • @rjsk464
    @rjsk464 Год назад +56

    Big Thanks to Akshay sir
    Pls bring the EP04, waiting for it.

    • @gaganbaghel8051
      @gaganbaghel8051 Год назад +1

      Ha Bhai daalo age k videos yaar jaldi jaldi

    • @akshaymarch7
      @akshaymarch7  11 месяцев назад +2

      Thank you so much for supporting my channel. This means a lot. ❤️

  • @jagrutsharma9150
    @jagrutsharma9150 Год назад +170

    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;
    }

    • @abhishekshimpi214
      @abhishekshimpi214 Год назад +2

      Thanks brother 🙏

    • @python-gamer9711
      @python-gamer9711 Год назад +20

      Bhai mai namaste javascript wali hrr ek video k comment section m tumko dhoondhta hu, video khatam hona k baad

    • @AYUSHKUMAR-ns3lt
      @AYUSHKUMAR-ns3lt Год назад +1

      @@python-gamer9711 His name is reflect is work... isin' tit. 😊

    • @harshmohite6297
      @harshmohite6297 Год назад +2

      Bhai aapka knowledge toh kamaal ka hai bhai.

    • @vivekbhatt3932
      @vivekbhatt3932 Год назад

      @@harshmohite6297 sahi baat hai

  • @abhishekkadavergu691
    @abhishekkadavergu691 Год назад +191

    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 🤗.

    • @akshaymarch7
      @akshaymarch7  Год назад +18

      Thank you so much for supporting my channel, Abhishek. This means a lot. ❤️

  • @IshantMehta01
    @IshantMehta01 Год назад +23

    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.

    • @akshaymarch7
      @akshaymarch7  Год назад

      Thank you so much for supporting my channel, Ishant. This means a lot. ❤️

  • @PumpkinEater6699
    @PumpkinEater6699 2 года назад +20

    Consistency at it's best❤️

    • @akshaymarch7
      @akshaymarch7  2 года назад +5

      Thank you so much for supporting my channel, Pravin. This means a lot. ❤️

    • @gvthabalasanmugam9031
      @gvthabalasanmugam9031 Год назад

      @@akshaymarch7 please make a video on arrow function

  • @SuperYog008
    @SuperYog008 Год назад +2

    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

  • @kamalapriyass2608
    @kamalapriyass2608 Год назад +3

    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!!

  • @kikish_sabina
    @kikish_sabina Год назад +1

    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❤👏👏👏

  • @DebojyotiMandal
    @DebojyotiMandal Год назад +65

    Most beautiful playlists on JavaScript.
    Binge watched the 23+4=27 videos in 3 days.
    *Please continue this series.*

  • @venkataramyasrikota8126
    @venkataramyasrikota8126 Год назад

    Just blown away when you said what happens when we just reject and do not handle errors.

  • @richeshkunwar2621
    @richeshkunwar2621 Год назад +5

    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

  • @VelvetWhisperCinemas
    @VelvetWhisperCinemas 2 месяца назад

    Brother Litterally Love u I could'nt Find Anyone Except you to explain things in this style solute u bro 💕💕

  • @manoharsingh1920
    @manoharsingh1920 Год назад +42

    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.

    • @akshaymarch7
      @akshaymarch7  Год назад +2

      Thank you so much for supporting my channel, Manohar. This means a lot. ❤️

    • @ram23gb
      @ram23gb Год назад +1

      @@akshaymarch7 bro when can we expect the next video

  • @ravikiran3871
    @ravikiran3871 Год назад

    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..... 😅😅

  • @ganeshkhirwadkar4127
    @ganeshkhirwadkar4127 Год назад +74

    Thanks a lot for all your awesome videos. I know and respect each and every efforts behind each video !

    • @akshaymarch7
      @akshaymarch7  Год назад +12

      Thank you so much for supporting my channel, Ganesh. This means a lot. ❤️

    • @ranjanbhat5607
      @ranjanbhat5607 Год назад +2

      Hi Ganesh. Y are u paying money to Akshay?

    • @ganeshkhirwadkar4127
      @ganeshkhirwadkar4127 Год назад +17

      @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 !

    • @ranjanbhat5607
      @ranjanbhat5607 Год назад +2

      @@ganeshkhirwadkar4127 that's great initiative from your side. I will also pay.
      Thanks for your ans👍☺️

    • @divyendumaurya9651
      @divyendumaurya9651 7 месяцев назад

      well answered@@ganeshkhirwadkar4127

  • @jitendramistry1241
    @jitendramistry1241 Год назад +1

    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.

  • @sarveshdevrukhakar
    @sarveshdevrukhakar 6 месяцев назад +14

    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.

  • @sanaumar3579
    @sanaumar3579 2 года назад +33

    Akshay you are great...you made me fall in love with JavaScript 😂... keep teaching us...lots of respect for you

  • @umarbusy
    @umarbusy Год назад +1

    Your videos should be at least 1 hour long.....they teaches us a lot, Take love from Pakistan 🇵🇰❤️🇮🇳

  • @karanfulare844
    @karanfulare844 Год назад +1

    lengthy videos are always good akshay bhai , I lost my job due to recession , i have 4 months of nodejs exp , job lagne par i will also support your channel like others , best wishesh waiting for next video . thank you for these videos.

  • @parwezalam-lo5rp
    @parwezalam-lo5rp Год назад +3

    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......

  • @IshantMehta01
    @IshantMehta01 Год назад

    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.

  • @keshavsharma4721
    @keshavsharma4721 2 года назад +11

    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 !

  • @niteshpandey8218
    @niteshpandey8218 9 месяцев назад

    When i see your videos , the fingers go automatically at the like button
    Seedhi baat no bakwaas ,love you ❤❤

  • @Anand4213
    @Anand4213 2 года назад +10

    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.

  • @prakharagrawal8983
    @prakharagrawal8983 Год назад

    Length of video is not a problem at all, we would love to hear you hours together with such lovely content.

  • @nishankarora3809
    @nishankarora3809 2 года назад +27

    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 :)

  • @jayesh1300
    @jayesh1300 Год назад

    Hii Akshay, waiting for the next video for the last 4 months, please upload new videos, initially, your videos are like a headache because it was too depth and lengthy but slowly realized that this was material that all freshers looking for to become good developers with a better understanding.

  • @pratyushkumar5885
    @pratyushkumar5885 Год назад +16

    Now onwards it's super easy to keep promises in mind.😅
    Thanks for this amazing content.😇

    • @akshaymarch7
      @akshaymarch7  Год назад +1

      Thank you so much for supporting my channel, Pratyush. This means a lot. Happy Diwali ❤️

    • @pratyushkumar5885
      @pratyushkumar5885 Год назад

      Happy Diwali 🎇🎇

  • @nandanithakur2172
    @nandanithakur2172 Год назад

    bahut ache se explain kiya hai . kahin aur se padhne ki jarurat hi nhi

  • @deadlock_33
    @deadlock_33 2 года назад +20

    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❤️

    • @himanshuarora1910
      @himanshuarora1910 Год назад +1

      bhai tu developer bna kaise fir

    • @Sanjeet287
      @Sanjeet287 Месяц назад

      @@himanshuarora1910 after creating to do list
      It is only a joke!

  • @Gvkrish52
    @Gvkrish52 2 года назад

    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..... 🙏✌

  • @sdsgfhgthjj
    @sdsgfhgthjj Год назад +13

    I binge-watched your JS series; Thank you for all the "Aha!" Moments. You are Pushpa and JS is Red-sanders; Thagede Le!

    • @dushyanthchowdary1388
      @dushyanthchowdary1388 Год назад +2

      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)
      }

    • @akshaymarch7
      @akshaymarch7  Год назад +1

      Thank you so much for supporting my channel. This means a lot. ❤️

  • @parmarkamlesh6493
    @parmarkamlesh6493 3 месяца назад

    Thank you for explaining this concepts.

  • @ameerentertainments2m434
    @ameerentertainments2m434 2 года назад +6

    Bro start teaching REACTJS. Your really great inspiration for me.

  • @manojkumarparuchuri5920
    @manojkumarparuchuri5920 3 месяца назад +1

    We want these type of content we will support you i will support you through your courses i will buy all your courses currently i bought your react course in future once i will get a job defnitely i will buy your frontend system design i am in hungry mode to learn your content

  • @heyitsdikshith4607
    @heyitsdikshith4607 Год назад +1

    You deeply dived in this topic Bro. Such a difficult topic you conway us easily. Once i got job i will defiantly give token thanks in $...
    Love your passion to teach ❤️

  • @aliragab5816
    @aliragab5816 2 года назад +5

    first like and first comment
    respect from egypt 🇪🇬
    Ali

  • @jitendramistry1241
    @jitendramistry1241 Год назад +1

    best wishesh waiting for next video . thank you for these videos.

  • @SabariKrishnan-lm2ew
    @SabariKrishnan-lm2ew Год назад +14

    Your videos helped me in cracking an interview

    • @akshaymarch7
      @akshaymarch7  Год назад +2

      Thank you so much for supporting my channel. This means a lot. ❤️

  • @robertobenedit
    @robertobenedit Год назад

    At the start it's struggles me, but at the end, i fully understand it. The multiple catch was great. Keep this way!

  • @omprakashmaurya4567
    @omprakashmaurya4567 2 года назад +57

    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.✍

    • @senthamarai_kannan.
      @senthamarai_kannan. Год назад +9

      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))

    • @rhimanshu6288
      @rhimanshu6288 Год назад

      Nicely written bro

    • @mdsharique9685
      @mdsharique9685 Год назад

      Awesome bro @omprakashmaurya

    • @mdsharique9685
      @mdsharique9685 Год назад

      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()

    • @mrvarma599
      @mrvarma599 Год назад +1

      @@senthamarai_kannan. You should return the parameters like order Id and proceedToPayment and all

  • @mariolopez1901
    @mariolopez1901 Год назад +4

    Like all your videos, it's excellent. I look forward to the ASYNC/AWAY theme. I hope you also consider the topic of GENERATORS.

  • @KrishnaKumar-ng9sx
    @KrishnaKumar-ng9sx Год назад +1

    Waiting for next video on promises like you mentioned combining result of two promises, etc.

  • @pavanyerra5944
    @pavanyerra5944 Год назад +8

    Your playlist helped me a lot in my career.
    Thanks Akshay

    • @akshaymarch7
      @akshaymarch7  Год назад

      Thank you so much Pavan, this means a lot! ♥️

  • @abbayrai6340
    @abbayrai6340 2 года назад +2

    Promise us to Teach forever 😍 🔥

  • @mind.flayer
    @mind.flayer 2 года назад +4

    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.

  • @imkrrishnayak
    @imkrrishnayak Год назад

    beyond words!! this is the best promise chaining video on internet!!! thanks buddy!

  • @stelena-forever
    @stelena-forever 9 месяцев назад +3

    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. ❤

  • @atanumalik5338
    @atanumalik5338 Год назад +1

    It was super fun for me to learn these concepts for the first time and from the best teacher. Thank you for everything🙏
    Here is my homework.
    ---------------------------------------------------------------------------------------------
    const cart = ["Shirt", "Jeans", "Shoes", "Watch"];
    let walletBalance = 10000;
    // Promise Chain
    createOrder(cart)
    .then(function(orderId){
    console.log(orderId);
    return orderId;
    })
    .then(function(orderId){
    return proceedToPayments(orderId)
    })
    .then(function(amount){
    console.log(`"Your payment of Rs. ${amount} is Successful`)
    return amount;
    })
    .then(function(amount){
    return showOrderSummary(amount);
    })
    .then(function(orderSummary){
    console.log(orderSummary)
    return orderSummary;
    })
    .then(function(amount){
    return updateWalletBalance(amount);
    })
    .then(function(updateWalletBalance){
    console.log(`Your updated wallet balance is ${updateWalletBalance}.`);
    return updateWalletBalance;
    })
    .catch(function(error){
    console.log(error.message);
    })
    ;
    // Create Order
    function createOrder(cart){
    return promise1 = new Promise(function (resolve, reject) {
    if(validOrder(cart)){
    const orderId = "76513";
    resolve(orderId);
    } else {
    const error = new Error("Your Cart is Empty");
    reject(error);
    }
    })
    }
    // Proceed to Payment
    function proceedToPayments(orderId){
    return promise2 = new Promise(function (resolve, reject){
    if(payment(orderId)){
    const amount = 4600;
    resolve(amount);
    } else{
    const error = new Error("Payment failed!")
    reject(error);
    }
    })
    }
    // Show order summery
    function showOrderSummary(amount){
    return promise3 = new Promise(function(resolve, reject){
    const orderSummary = amount;
    resolve(orderSummary);
    const error = new Error("Something went wrong!")
    reject(error);
    })
    }
    // Update Wallet Balance
    function updateWalletBalance(amount){
    return promise4 = new Promise(function(resolve, reject){
    const updatedWalletBalance = walletBalance-amount;
    resolve(updatedWalletBalance);
    const error = new Error("Failed to update wallet balance")
    reject(error);
    })
    }
    // Payment
    function payment(){
    return true;
    }
    // Validating order
    function validOrder(){
    if(cart.length == 0) return false
    else return true;
    }

  • @rakshitpatel9664
    @rakshitpatel9664 Год назад

    you are legend in JavaScript world

  • @kawsersimanto1672
    @kawsersimanto1672 Год назад +7

    waiting for episode 4, hope you will make it fast.🥰🥰

  • @nitinak7837
    @nitinak7837 Год назад +1

    Please make video on Object oriented programming Akshay

  • @rakshithkn4637
    @rakshithkn4637 9 месяцев назад

    Promise is an object which represent the evntual completion of assynchronous operation
    Advantages :It avoid the problem arising from the call back hel which creates the pyramid like structure horizontally which is not able to understand the code when others seen first
    And inversion of control
    And it is in a structured formate and like we can easily execute the task with consecutively which is good one

  • @swapnilmitpalliwar6631
    @swapnilmitpalliwar6631 Год назад +4

    The way you explain the concepts is awesome. If you can also create videos on oops and solid principals, it would be very useful.

  • @yasirsarole8654
    @yasirsarole8654 Год назад

    Thank You Akshay for creating such videos with in-depth clarity. Looking forward to more episodes of season 2.

  • @chandraprakashsharma1495
    @chandraprakashsharma1495 Год назад +3

    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" . 👍

  • @kria2029
    @kria2029 Месяц назад

    1.resolve accepts only one argument (if we have more arguments either pass through object or array )
    2.By using the Promise constructor we can new promise and inside the promise we need to give the call back function with passing resolve and reject
    3.two phases creation phase and consuming phase
    4..then() must and should return new promise if we wish to extend the .then()(promise chain)

  • @kajalchandravanshi2456
    @kajalchandravanshi2456 Год назад

    sir, please continue this series... i am really enjoying it

  • @nour.m8205
    @nour.m8205 Год назад +4

    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!

  • @narayanchatalwar8027
    @narayanchatalwar8027 2 года назад

    Your videos and your way of explainig is really great . Worth every second ...

  • @razarajpoot9811
    @razarajpoot9811 8 месяцев назад +4

    The best part of your all videos is "Your smile at end" 😃😅 Tremendous

    • @razarajpoot9811
      @razarajpoot9811 8 месяцев назад

      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.💝🥰😍

    • @poojamahtha2780
      @poojamahtha2780 7 месяцев назад +1

      Totally... the happiness we all resonate with :)

  • @ankitkansal474
    @ankitkansal474 Год назад

    Please continue this series.

  • @martinjoseph9939
    @martinjoseph9939 Год назад +6

    Thanks!

    • @akshaymarch7
      @akshaymarch7  Год назад +1

      Thank you so much for supporting my channel, Martin. This means a lot. ❤️

  • @ankitkansal474
    @ankitkansal474 Год назад

    Please continue this series.

  • @sandeepcv5501
    @sandeepcv5501 Год назад +6

    Thanks

    • @akshaymarch7
      @akshaymarch7  Год назад

      Thank you so much for supporting my channel, Sandeep. This means a lot. ❤️

  • @aniketjoshi4179
    @aniketjoshi4179 8 месяцев назад

    promises are important to maintain the trust for example when the coontrol of program is send to particular api then we cant rely on what will it return that is it can return 2 times the value or nothing so promises store the value return in a empty container and then using .then they can be called

  • @shivaliraghav8524
    @shivaliraghav8524 2 года назад +3

    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

  • @akshay6023
    @akshay6023 Год назад

    Please cover all concepts and don't worry about the length of videos 🙏

  • @johnbrando8391
    @johnbrando8391 Год назад +5

    Thanks!

    • @akshaymarch7
      @akshaymarch7  Год назад

      Thank you so much for supporting my channel, John. This means a lot. ❤️

  • @trendinginsaan1285
    @trendinginsaan1285 9 месяцев назад

    (shorts) => { return "beneficial over short time" }
    (long_videos) => { return "beneficial long time" }

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 Год назад +4

    No words :) Just amazing you made the promise so easy to understand waiting for more such content 😎🔥🚀

    • @abhishekvishwakarma9045
      @abhishekvishwakarma9045 Год назад

      @Akshay saini sir i think you need to look into this looks scam to me 🤔

    • @WestcolColombia_
      @WestcolColombia_ Год назад

      @@abhishekvishwakarma9045 yeahhhhhh many comments have this reply

  • @YogeshKarpe
    @YogeshKarpe Год назад +1

    This can be easily done with async await. please cover that in upcoming videos. thanks in advance

  • @vipulpawaskar
    @vipulpawaskar Год назад +4

    Thanks Akshay...

    • @akshaymarch7
      @akshaymarch7  Год назад +1

      Thank you so much for supporting my channel, Vipul. This means a lot. ❤️

  • @mohammadzahid2202
    @mohammadzahid2202 Год назад +1

    waiting for next epi.

  • @arshalanfaiz9501
    @arshalanfaiz9501 7 месяцев назад

    level of stufs are really good .

  • @KiranKumari-fv3qq
    @KiranKumari-fv3qq Год назад +2

    hey Akshay, when is Async await video coming up?

  • @AhireMahesh
    @AhireMahesh Год назад

    Loving and learning your videos, please create such videos..worth watching your videos bro.. you’re awesome ❤

  • @sayantankapat7472
    @sayantankapat7472 Год назад

    A video on async await will be very helpful.

  • @poonamchaurasia2484
    @poonamchaurasia2484 Год назад +1

    Really valuable content Akshay!! Thanks a lot for all your endeavor 😊
    Looking forward for more such helpful content😁

  • @sarthakgupta5064
    @sarthakgupta5064 10 месяцев назад

    The explanation for last "then" to be executed is that "catch" also returns a "promise" which is then-able.Therefore , the last then is executed.

  • @jay8118
    @jay8118 Год назад +2

    Why are you very slow in putting videos

    • @mudassirkhan5036
      @mudassirkhan5036 Год назад

      He started namaste react

    • @jay8118
      @jay8118 Год назад +1

      Bahot mehenga hai...🥶🥶

    • @jay8118
      @jay8118 Год назад

      Delaying JavaScript for Teaching REACT is very very Wrong decision. When he is putting 1 video per month to aage ka kese yaad rahega...

  • @PoojaVerma-sl6mg
    @PoojaVerma-sl6mg 7 месяцев назад

    Hi Akshay , Your tutorials are extremely helpful. I just wanted to ask you how you obtain auto suggestions for the next code, also did you use any extensions for it.

  • @madhvimittal8266
    @madhvimittal8266 Год назад

    Need a video on JS is single threaded or multi-threaded and libuv explanation pleaseeeeee

  • @sourabhkulkarni1731
    @sourabhkulkarni1731 Год назад

    Make lengthy videos with in-depth information, thank you in advance.

  • @RS-iy2bm
    @RS-iy2bm 2 года назад

    Lot of respect for you brother.

  • @kawsersimanto
    @kawsersimanto Год назад

    thanks it was so helpful, waiting for next episode

  • @nagarajmakanna9405
    @nagarajmakanna9405 2 года назад

    It was cristal clear superb.....
    Why don't you give Fake API calls to give more precise on resolve()👍

  • @krishmabhatia696
    @krishmabhatia696 Год назад +1

    Thanks Akshay for the wonderful video.When will we have next video(EP 4) in season 2? Waiting for it :)

  • @mrankushtechnical
    @mrankushtechnical Год назад

    26:12 i have doubt here the orderId is just a simple datatype , not promise right ? so how you can use then after it... we can use then only when the returned object is promise right ?

    • @ashwinnair9862
      @ashwinnair9862 Год назад

      not really you can pass in data or promise through then block

  • @cenacr007
    @cenacr007 Год назад +1

    7 months have passed, seems Akshay forgot about his youtube channel.

  • @mrankushtechnical
    @mrankushtechnical Год назад +1

    11:11 if it runs the reject then it will not go down the line, (line 19)

  • @VINAYAKJAISWAL-m9f
    @VINAYAKJAISWAL-m9f 6 месяцев назад +1

    You had the option to name this video “Promise-chan” and you missed it😂

  • @rajeevranjansingh7103
    @rajeevranjansingh7103 Год назад

    huge respect

  • @AnshikaTomar-mg2fm
    @AnshikaTomar-mg2fm Год назад +1

    Excellent video! One doubt only when you wrote the last code, you used catch two time. One after the catch order and one after the payment info. But it get printed only once. Why does that happen? Please resolve

  • @ferdousahmed7024
    @ferdousahmed7024 Год назад

    Upload more videos in this season, please!

  • @jaipurite.k_lalit
    @jaipurite.k_lalit 2 года назад +1

    love you millions time💖💖💖💖💖💖.....💖💖and a million times thanks