What is JavaScript CALLBACK HELL? 🔥

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

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

  • @BroCodez
    @BroCodez  Год назад +20

    // 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 День назад +1

    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 месяцев назад +5

    The explaination is just awesome

  • @EliasVargas-v7e
    @EliasVargas-v7e 3 месяца назад

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

  • @legendrags
    @legendrags Год назад +21

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

  • @fakenot1223
    @fakenot1223 Месяц назад +3

    thanks a lot i really mean it !!

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

  • @hwapyongedouard
    @hwapyongedouard 8 месяцев назад +1

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

  • @DipesMandaviya
    @DipesMandaviya 8 месяцев назад +1

    simplest and easy style to teach

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

    Clean explanation!👏

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

    Nice explanation

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

    Very good explanation :D

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

    Amazing video in 5 mins

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

    Thank you! Thats helpful!

  • @bhuviramesh8218
    @bhuviramesh8218 9 месяцев назад +1

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

  • @OmKar-xc3mc
    @OmKar-xc3mc 6 месяцев назад

    THIS SURELY IS WOUNDERFULL

  • @brijeshprasaddas249
    @brijeshprasaddas249 6 месяцев назад +1

    This video saved my life

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

    Thank you so much

  • @majidmohd100
    @majidmohd100 4 месяца назад

    Tysm😊

  • @Usha-h1d
    @Usha-h1d 4 месяца назад +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 4 месяца назад

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

  • @divyaanshuagrawal3383
    @divyaanshuagrawal3383 5 месяцев назад +1

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

    • @sacramagic
      @sacramagic 4 месяца назад

      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.

  • @indian-shorts9215
    @indian-shorts9215 Год назад

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

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

    0:52 tasks were complete! 💪💋!

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

      1:46

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

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

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

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

    bro i wanna know who r u

  • @deadmarshal
    @deadmarshal 11 месяцев назад

    JS is a joke!