What is JavaScript CALLBACK HELL? 🔥

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025
  • #JavaScript #tutorial #course
    // Callback Hell = Situation in JavaScript where callbacks
    // are nested within other callbacks to the
    // degree where the code is difficult to read.
    // Old pattern to handle asynchronous functions.
    // Use Promises + async/await to avoid Callback Hell

ความคิดเห็น • 39

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

    // Callback Hell = Situation in JavaScript where callbacks
    // are nested within other callbacks to the
    // degree where the code is difficult to read.
    // Old pattern to handle asynchronous functions.
    // Use Promises + async/await to avoid Callback Hell
    function task1(callback){
    setTimeout(() => {
    console.log("Task 1 complete");
    callback();
    }, 2000);
    }
    function task2(callback){
    setTimeout(() => {
    console.log("Task 2 complete");
    callback();
    }, 1000);
    }
    function task3(callback){
    setTimeout(() => {
    console.log("Task 3 complete");
    callback();
    }, 3000);
    }
    function task4(callback){
    setTimeout(() => {
    console.log("Task 4 complete");
    callback();
    }, 1500);
    }
    task1(() => {
    task2(() => {
    task3(() => {
    task4(() => console.log("All tasks completed"));
    })
    });
    })

  • @LearnWithAmi
    @LearnWithAmi 17 วันที่ผ่านมา +2

    the way you explained it...amazing

  • @Soulcode-k
    @Soulcode-k หลายเดือนก่อน +1

    What a great time to be alive 😊.
    I don't have to right this sh** because of async function.
    I agree that this is a hell.

  • @Anonymous-cw7nx
    @Anonymous-cw7nx 6 หลายเดือนก่อน +6

    The explaination is just awesome

  • @EliasVargas-v7e
    @EliasVargas-v7e 4 หลายเดือนก่อน

    I was about to jump out of the building because I couldn't understand how this worked, thanks, you're the GOAT

  • @abcdabcd8605
    @abcdabcd8605 9 หลายเดือนก่อน +3

    Awesome explanation

  • @peace-o-mind
    @peace-o-mind ปีที่แล้ว +2

    Thanks for the vid bro. It was helpful to actually visualize callback hell. Waiting for async/await video. I have to learn async/await.

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

      That's coming up after promises

  • @DipesMandaviya
    @DipesMandaviya 8 หลายเดือนก่อน +1

    simplest and easy style to teach

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

    thanks a lot i really mean it !!

  • @hwapyongedouard
    @hwapyongedouard 9 หลายเดือนก่อน +1

    just learned all JavaScript from bro now i understand call backs and asnch js

  • @legendrags
    @legendrags ปีที่แล้ว +24

    Better title would be "What the hell is callback hell?"

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

    Clean explanation!👏

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

    Very good explanation :D

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

    Nice explanation

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

    Amazing video in 5 mins

  • @mr.nobody9344
    @mr.nobody9344 9 วันที่ผ่านมา

    tnx

  • @brijeshprasaddas249
    @brijeshprasaddas249 6 หลายเดือนก่อน +1

    This video saved my life

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

    Thank you! Thats helpful!

  • @OmKar-xc3mc
    @OmKar-xc3mc 6 หลายเดือนก่อน

    THIS SURELY IS WOUNDERFULL

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

    Tysm😊

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

    Thank you so much

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

    If you want to execute the task one after the other why go for async, you should have used synchronous itself nah?

  • @Usha-h1d
    @Usha-h1d 5 หลายเดือนก่อน +1

    Sir,do you have notes for JavaScript

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

    Why write in JS if you aren't writing a non probable callback hell?

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

    function task1(){
    console.log("Task 1")
    }
    function task2(){
    console.log("Task 2")
    }
    A callback hell is something like
    function task1(){
    task2(){
    ...
    }
    }
    Am I right ?

  • @indian-shorts9215
    @indian-shorts9215 ปีที่แล้ว

    If you make DSA in Js that’s the thing that everybody

  • @divyaanshuagrawal3383
    @divyaanshuagrawal3383 5 หลายเดือนก่อน +1

    cant we just call task1(task2(task3(task4(task5))))) ?

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

      That's what I was thinking too. There must be something else we are not taking into account for him to add all that extra code to his example.

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

    love how you didnt offer any solution or pattern to that problem.

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

      That's the next video on promises

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

      @@BroCodez yay!! i can't wait!😁
      Nice channel btw, keep up the good work!🔥

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

    0:52 tasks were complete! 💪💋!

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

      1:46

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

      Читать легче. На слух очень плохо воспринимаю.

  • @offlinehub
    @offlinehub 8 หลายเดือนก่อน

    bro i wanna know who r u

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

    JS is a joke!