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

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 1K

  • @sujit510
    @sujit510 2 ปีที่แล้ว +193

    Excellent stuff, Thanks Akshay!

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว +29

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

    • @sujit510
      @sujit510 2 ปีที่แล้ว +15

      @@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 2 ปีที่แล้ว +12

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

    • @ayushi8412
      @ayushi8412 2 ปีที่แล้ว +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 2 ปีที่แล้ว

      @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 ปีที่แล้ว +250

    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 ปีที่แล้ว +2

      always

    • @mayukhdevansahu5707
      @mayukhdevansahu5707 2 ปีที่แล้ว +2

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

    • @dakshlakhotiya4275
      @dakshlakhotiya4275 2 ปีที่แล้ว

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

    • @yogeshkataria9741
      @yogeshkataria9741 2 ปีที่แล้ว +4

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

    • @AbhishekPal-666
      @AbhishekPal-666 2 ปีที่แล้ว

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

  • @sarveshdevrukhakar
    @sarveshdevrukhakar 8 หลายเดือนก่อน +20

    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.

  • @abhishekkadavergu691
    @abhishekkadavergu691 2 ปีที่แล้ว +207

    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  2 ปีที่แล้ว +18

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

  • @rjsk464
    @rjsk464 ปีที่แล้ว +61

    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  ปีที่แล้ว +3

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

  • @SabariKrishnan-lm2ew
    @SabariKrishnan-lm2ew ปีที่แล้ว +15

    Your videos helped me in cracking an interview

    • @akshaymarch7
      @akshaymarch7  ปีที่แล้ว +4

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

  • @sdsgfhgthjj
    @sdsgfhgthjj 2 ปีที่แล้ว +14

    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 ปีที่แล้ว +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. ❤️

  • @jagrutsharma9150
    @jagrutsharma9150 ปีที่แล้ว +185

    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 ปีที่แล้ว +21

      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

  • @manoharsingh1920
    @manoharsingh1920 2 ปีที่แล้ว +45

    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  ปีที่แล้ว +3

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

    • @ram23gb
      @ram23gb ปีที่แล้ว +2

      @@akshaymarch7 bro when can we expect the next video

  • @ganeshkhirwadkar4127
    @ganeshkhirwadkar4127 2 ปีที่แล้ว +77

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

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว +14

      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 ปีที่แล้ว +18

      @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 9 หลายเดือนก่อน

      well answered@@ganeshkhirwadkar4127

  • @DebojyotiMandal
    @DebojyotiMandal ปีที่แล้ว +70

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

  • @pavanyerra5944
    @pavanyerra5944 ปีที่แล้ว +10

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

    • @akshaymarch7
      @akshaymarch7  ปีที่แล้ว +1

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

  • @keshavsharma4721
    @keshavsharma4721 2 ปีที่แล้ว +13

    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 !

  • @PumpkinEater6699
    @PumpkinEater6699 2 ปีที่แล้ว +21

    Consistency at it's best❤️

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว +5

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

    • @gvthabalasanmugam9031
      @gvthabalasanmugam9031 2 ปีที่แล้ว

      @@akshaymarch7 please make a video on arrow function

  • @pratyushkumar5885
    @pratyushkumar5885 2 ปีที่แล้ว +17

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

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว +1

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

    • @pratyushkumar5885
      @pratyushkumar5885 2 ปีที่แล้ว

      Happy Diwali 🎇🎇

  • @nishankarora3809
    @nishankarora3809 2 ปีที่แล้ว +29

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

  • @sanaumar3579
    @sanaumar3579 2 ปีที่แล้ว +34

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

  • @spillthebuzz
    @spillthebuzz ปีที่แล้ว +116

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

  • @johnbrando8391
    @johnbrando8391 2 ปีที่แล้ว +6

    Thanks!

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว

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

  • @vipulpawaskar
    @vipulpawaskar 2 ปีที่แล้ว +5

    Thanks Akshay...

    • @akshaymarch7
      @akshaymarch7  ปีที่แล้ว +1

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

  • @sandeepcv5501
    @sandeepcv5501 2 ปีที่แล้ว +7

    Thanks

    • @akshaymarch7
      @akshaymarch7  2 ปีที่แล้ว

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

  • @Anand4213
    @Anand4213 2 ปีที่แล้ว +11

    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.

  • @deadlock_33
    @deadlock_33 2 ปีที่แล้ว +22

    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 3 หลายเดือนก่อน

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

  • @razarajpoot9811
    @razarajpoot9811 10 หลายเดือนก่อน +6

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

    • @razarajpoot9811
      @razarajpoot9811 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน +1

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

  • @explore_with_sim
    @explore_with_sim 3 หลายเดือนก่อน +2

    Bing watched both seasons in 2 days.. nd a big big thanks from bottom of my heart.. thanku sir ✨️

  • @stelena-forever
    @stelena-forever 11 หลายเดือนก่อน +4

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

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

  • @poojalahane2584
    @poojalahane2584 7 หลายเดือนก่อน +1

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

  • @shanmukhbharadwaj1520
    @shanmukhbharadwaj1520 ปีที่แล้ว +1

    This is the bestesttt JS course I have found on internet. Please just do not stop this course. That's all we wish for 🙏.

  • @aliragab5816
    @aliragab5816 2 ปีที่แล้ว +5

    first like and first comment
    respect from egypt 🇪🇬
    Ali

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

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

  • @subhashinisahu3398
    @subhashinisahu3398 ปีที่แล้ว +1

    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.

  • @chandraprakashsharma1495
    @chandraprakashsharma1495 2 ปีที่แล้ว +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" . 👍

  • @WestcolColombia_
    @WestcolColombia_ 2 ปีที่แล้ว +2

    THANKKKKK YOUUUUUUU, THE BEST SURPRISE, 2 VIDEOS IN A WEEK YEAHHHH

    • @WestcolColombia_
      @WestcolColombia_ 2 ปีที่แล้ว

      I don't understand hahaha, am I the winner? Where do I text you, I'm impressed

    • @WestcolColombia_
      @WestcolColombia_ 2 ปีที่แล้ว

      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?

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

  • @abhishek_osu
    @abhishek_osu ปีที่แล้ว +1

    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.

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 2 ปีที่แล้ว +4

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

    • @abhishekvishwakarma9045
      @abhishekvishwakarma9045 2 ปีที่แล้ว

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

    • @WestcolColombia_
      @WestcolColombia_ 2 ปีที่แล้ว

      @@abhishekvishwakarma9045 yeahhhhhh many comments have this reply

  • @harishkanuka
    @harishkanuka 9 หลายเดือนก่อน

    00:00 🚀 Promises simplify asynchronous operations in JavaScript, enhancing code readability and developer productivity.
    00:27 💼 The episode covers creating custom promises, error handling, and promise chaining with practical examples.
    01:12 🛒 Example scenario: Creating an order in an e-commerce website using asynchronous operations.
    02:03 🔗 Creating a promise involves using the Promise constructor with resolve and reject functions.
    03:12 📝 Promises allow developers to control when asynchronous operations succeed (resolve) or fail (reject).
    08:31 🔍 Gracefully handle promise rejections using the catch method to avoid silent errors in production.
    15:10 🔄 Promise chaining enables sequential execution of asynchronous tasks, passing data between them for streamlined workflows.
    20:13 🎯 Promise chaining allows passing data between asynchronous operations, simplifying complex workflows.
    20:55 🔄 Promises are crucial for handling asynchronous operations, such as handling payments in an e-commerce scenario.
    23:23 ❌ A common error in promise chaining is forgetting to return values down the chain, leading to unexpected behaviour and difficult debugging.
    24:31 🔗 To pass data down the promise chain, always return the necessary values or promises from each link in the chain.
    26:33 🛑 The catch method is essential for handling errors in promise chains, ensuring graceful error handling throughout the chain.
    28:27 🔄 Placing a catch statement strategically allows specific error handling for different parts of the promise chain, ensuring robust error management.
    30:01 🔄 Regardless of errors, the 'then' method following a 'catch' statement will always be executed, providing a reliable continuation point in the chain.
    32:30 📚 A recap of key concepts covered: creating promises, error handling with catch, and chaining promises for sequential asynchronous operations.
    36:14 📝 Homework assignment: Create a promise chain simulating an e-commerce scenario with four async operations, emphasizing proper chaining and error handling.

  • @kawsersimanto1672
    @kawsersimanto1672 2 ปีที่แล้ว +7

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

  • @Rajveer__singhhhh
    @Rajveer__singhhhh 10 หลายเดือนก่อน

    Your are great teacher my life is changed after watching namaste javascript and my confidence level boost towards coding.

  • @omprakashmaurya4567
    @omprakashmaurya4567 2 ปีที่แล้ว +61

    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. 2 ปีที่แล้ว +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

  • @AbhayRai-t4e
    @AbhayRai-t4e 2 ปีที่แล้ว +3

    Promise us to Teach forever 😍 🔥

    • @AsadKhan-it2tw
      @AsadKhan-it2tw 7 ชั่วโมงที่ผ่านมา

      hahahaha good!

  • @javascriptEager
    @javascriptEager 2 ปีที่แล้ว

    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.

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

  • @vickykumargupta605
    @vickykumargupta605 ปีที่แล้ว +2

    Akshay, I am astounded by the quality of your content! I will be eternally grateful for your content.

  • @ameerentertainments2m434
    @ameerentertainments2m434 2 ปีที่แล้ว +6

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

  • @namratacareer
    @namratacareer 2 ปีที่แล้ว +1

    I am a react developer ,For any interview I just go through your videos and I overcome many interviews.

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

  • @TW-uk1xi
    @TW-uk1xi 9 หลายเดือนก่อน

    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.

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

  • @Sourabhsharmaofficial
    @Sourabhsharmaofficial 2 ปีที่แล้ว +1

    you are my favorite youtuber eveytime i have doubt i find videos from your playlist bro. just a suggestion please as you have already made season 1 and season 2 please make videos on js basics too so that we can get all stuff from your chanel then there is no need of other chaneels . i am really thankfull to you for your wonderfull userfull efforts. may lord krishna bless you with good health wealth and happines.wishes from my core of the heart.

  • @niteshrathore4341
    @niteshrathore4341 ปีที่แล้ว +1

    Please continue with this series need this series to be watched by millions of user

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

  • @mithleshfantezie
    @mithleshfantezie 2 ปีที่แล้ว +1

    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 🙏

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

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

  • @rishabh_shukla20
    @rishabh_shukla20 ปีที่แล้ว +1

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

  • @theblackelephant
    @theblackelephant ปีที่แล้ว

    OHH my God am in love with your teaching, even as a person with 3+ years experience, I respect your level of explanation.

  • @galaxy792
    @galaxy792 7 หลายเดือนก่อน

    This video covers the creation and handling of promises in JavaScript, including promise chaining, error handling, and advanced promise concepts. The summary and related questions are as follows:
    Key moments:
    00:00 Promises in JavaScript simplify handling asynchronous operations. Creating and consuming promises enhances JavaScript development skills and boosts confidence in writing asynchronous code.
    -Understanding the concept of promises in JavaScript and their significance in simplifying asynchronous operations.
    -Creating custom promises in JavaScript, handling errors within promises, and exploring promise chaining.
    -Enhancing JavaScript development skills by learning to write and consume custom promises, gaining confidence in asynchronous coding.
    06:05 Creating a promise involves returning either success with an order ID or failure with an error, demonstrating the producer end and the logic behind resolving or rejecting promises.
    -Handling promise rejection by throwing an error when the card validation fails, utilizing the reject function in JavaScript.
    -Resolving a promise by passing the order ID upon successful creation, showcasing the resolve function's role in promise fulfillment.
    12:09 Creating and consuming promises in JavaScript involves resolving and rejecting promises, handling success and failure callbacks, and ensuring graceful error handling for a better user experience.
    -Resolving a promise involves attaching a success callback to handle data retrieval and logging the order ID upon successful resolution.
    -Delaying promise resolution using setTimeout simulates asynchronous operations, showcasing the importance of handling asynchronous code execution.
    -Rejecting a promise triggers the failure callback, emphasizing the need for error handling to prevent silent failures in production code.
    18:12 The video discusses handling promises in JavaScript, demonstrating promise chaining and the importance of correctly returning values in promise chains for successful execution.
    -Explaining promise chaining and its implementation in JavaScript, showcasing real-life examples and the process of proceeding to payment using promises.
    -Demonstrating the correct way to handle promise chains by ensuring values are passed down the chain for successful execution, highlighting common errors in promise chaining.
    24:17 Returning promises in JavaScript helps avoid callback hell by chaining promises, handling errors with catch, and passing data between chain levels, creating a structured and manageable code flow.
    -Handling errors with catch in promise chains ensures graceful error handling and prevents the entire chain from failing due to a single error, maintaining code integrity.
    -Chaining promises allows passing data between different levels of the chain, enabling seamless flow of information and actions in JavaScript programming.
    -Using catch statements strategically in promise chains can control error handling at specific points, allowing for customized error management and continued execution of subsequent steps.
    30:19 Promise chaining simplifies error handling and code readability. It helps avoid callback hell, making code more maintainable and developer-friendly.
    -Creating new promises involves using the Promise Constructor and resolving or rejecting them based on conditions, ensuring control over promise outcomes.
    -Error handling in promises is done by attaching a catch method to gracefully handle errors thrown during promise execution, enhancing program robustness.
    -Chaining promises involves returning values in each 'then' block to progress through the chain, and strategically placing catch methods for specific error handling scenarios.
    36:22 The video discusses the concept of promise chaining in JavaScript using an example of an e-commerce website with four asynchronous APIs. It emphasizes the importance of handling errors and writing code in a structured manner.
    -Importance of promise chaining in handling asynchronous operations sequentially for creating orders, proceeding to payment, showing order summary, and updating wallet balance.
    -Emphasis on structuring code by creating a promise chain to ensure step-by-step execution of async functions and proper error handling.
    Generated by sider.ai

  • @divyanshsinghbhati6026
    @divyanshsinghbhati6026 ปีที่แล้ว

    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 .

  • @eshaanbagga5159
    @eshaanbagga5159 2 ปีที่แล้ว +1

    Lengthy videos are never an issue Akshay sir, getting the knowledge about each n everything in depth is what matters!

  • @venkataramyasrikota8126
    @venkataramyasrikota8126 ปีที่แล้ว

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

  • @VelvetWhisperCinemas
    @VelvetWhisperCinemas 5 หลายเดือนก่อน

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

  • @muhammadnaveed7953
    @muhammadnaveed7953 2 ปีที่แล้ว

    Akshay you are real champion of JavaScript... Thankyou..
    Please keep teaching us...
    And upload one video daily

  • @apurvasingh5643
    @apurvasingh5643 2 ปีที่แล้ว +15

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

    • @mseditx1334
      @mseditx1334 3 หลายเดือนก่อน +1

      Bhai mujhe ek problem hey
      Mujhe code smjh aa jata hey lekin khud se likh nhi pata hu😢
      Kuch usefull tips dedo

    • @patelyash.1422
      @patelyash.1422 หลายเดือนก่อน +1

      @@mseditx1334 start with simple code and do practice
      don't jump to direct large code

  • @BHUVANESHWARANS-o1i
    @BHUVANESHWARANS-o1i 7 หลายเดือนก่อน

    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😄

  • @bloggerayush8550
    @bloggerayush8550 ปีที่แล้ว

    What a Quality content yaar. All of my doubt cleared in a single video

  • @niteshpandey8218
    @niteshpandey8218 11 หลายเดือนก่อน

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

  • @Zaheer__zk40
    @Zaheer__zk40 ปีที่แล้ว

    great explanation, The Best part that every TH-cam teacher should add to their videos is homework as this videos homework, Thanks for creating such great tutorials

  • @lucifersrivastava2479
    @lucifersrivastava2479 10 หลายเดือนก่อน +1

    Bro make it as much long as you want I am here to learn the concept doesnt matter how much time it takes.
    Keep going brother❤

  • @AbdulRehman-pk4nu
    @AbdulRehman-pk4nu 11 วันที่ผ่านมา

    Hey dude...
    Your way of teaching is fabulous i wanna just say i learn promise easily very easily thanks dude. ❤

  • @dieshimitigert6758
    @dieshimitigert6758 ปีที่แล้ว +1

    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!

  • @narenshalivahana1111
    @narenshalivahana1111 ปีที่แล้ว

    the favourite part of your vedio is last 15sec music, love you akshay saini

  • @arunshukla5767
    @arunshukla5767 ปีที่แล้ว

    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

  • @mayur_madhwani03
    @mayur_madhwani03 2 ปีที่แล้ว

    I've a test tomorrow and JS is in the syllabus and here is your video that'll help me
    Grateful

  • @digital_earnings
    @digital_earnings 4 หลายเดือนก่อน

    We just love ashkay as we love javascript literally Big thanks to you man

  • @sunilkumar-zf4dx
    @sunilkumar-zf4dx 2 ปีที่แล้ว +1

    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.

  • @AkashYadav-n3k7c
    @AkashYadav-n3k7c 8 หลายเดือนก่อน

    continue with detailed video like these ...it will get better reach
    and thanks for clear explanation.

  • @pranshuaggarwal
    @pranshuaggarwal ปีที่แล้ว

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

  • @yashsuthar3172
    @yashsuthar3172 2 ปีที่แล้ว +1

    you are very good teacher so far on youtube.
    I've watched all season 1 video and watching season 2 as well.

  • @bhavaniprasad2707
    @bhavaniprasad2707 5 หลายเดือนก่อน

    Hahaha last few seconds r crazy byhearting definition 😅😅😅 u explaintion is awesome

  • @ntnpawar37
    @ntnpawar37 6 หลายเดือนก่อน

    Solved all my doubts related to Promises. Thanks a lot. Keep up the good work.

  • @LifeLogic-Insights
    @LifeLogic-Insights 8 หลายเดือนก่อน +2

    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❤

  • @k.ashutoshbaitharu3964
    @k.ashutoshbaitharu3964 ปีที่แล้ว

    Akshay is the cool prgramming Big brother we never had, Thank you so much!!

  • @nandanithakur2172
    @nandanithakur2172 ปีที่แล้ว

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

  • @ravikiran3871
    @ravikiran3871 2 ปีที่แล้ว

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

  • @vipulsharma9
    @vipulsharma9 10 หลายเดือนก่อน

    You really made me love these things. Thanks a lot Akshay!
    The way you teach, it feels like I am taking personal coaching from my buddy. You are great brother! I am thinking to complete all React and Javascript courses from you.

  • @dipenchavda6988
    @dipenchavda6988 2 ปีที่แล้ว +2

    Please bring the next videos as soon as possible we are just loving this series.

  • @akshay-kumar-007
    @akshay-kumar-007 2 ปีที่แล้ว

    The function passed as callback inside Promise constructor is called and "executor" and this way of creating a Promise is called revealing-constructor because resolve and reject are revealed to executor by Promise constructor.
    Also, at 30:57 we should use .finally(() => {...}) instead of .then(() => {...})

  • @sakshimore4275
    @sakshimore4275 7 หลายเดือนก่อน

    The best explanation on promises ever!

  • @shree1365
    @shree1365 2 ปีที่แล้ว

    ground m jaddu bhai kamal krte h or ynha aap both are ❤️❤️❤️❤️

  • @KhushbooPandey-cd7ln
    @KhushbooPandey-cd7ln ปีที่แล้ว

    its wonderful stuff, I gone through many video i was not able to understand what exactly it is but by this i just love with promise concept...thanxx akshay

  • @georgesnordon6696
    @georgesnordon6696 ปีที่แล้ว

    A great video just like the previous one (Consuming a promise)...now I have to do my home work !

  • @jitendramistry1241
    @jitendramistry1241 ปีที่แล้ว +1

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

  • @kovendanragupathi7632
    @kovendanragupathi7632 2 ปีที่แล้ว

    Finally I really like you are uploading videos consistently. THANK YOU SO MUCH BRO

  • @mahesh_a
    @mahesh_a ปีที่แล้ว +1

    Episode 4 Please. Very excited for it :)

  • @vinaypatil8009
    @vinaypatil8009 2 ปีที่แล้ว

    Too much great information in 1 video.
    Truly amazing and one of the best channel to learn JavaScript
    Thanks for everything sir

  • @rohanmahajan6129
    @rohanmahajan6129 ปีที่แล้ว

    Simply Great this man is, his series is, and also the way he teaches these complex things, makes so much easy for uss to understand, god bless yh man, bro please keep continuing the series!!!

  • @umarbusy
    @umarbusy ปีที่แล้ว +1

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