What is JavaScript CALLBACK HELL? 🔥

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

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

  • @BroCodez
    @BroCodez  11 месяцев назад +19

    // 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"));
    })
    });
    })

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

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

  • @legendrags
    @legendrags 10 месяцев назад +16

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

  • @Anonymous-cw7nx
    @Anonymous-cw7nx 4 месяца назад +2

    The explaination is just awesome

  • @hwapyongedouard
    @hwapyongedouard 6 месяцев назад

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

  • @DipesMandaviya
    @DipesMandaviya 6 месяцев назад

    simplest and easy style to teach

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

    This video saved my life

  • @abcdabcd8605
    @abcdabcd8605 7 месяцев назад +2

    Awesome explanation

  • @peace-o-mind
    @peace-o-mind 11 месяцев назад +1

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

      That's coming up after promises

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

    Amazing video in 5 mins

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

    THIS SURELY IS WOUNDERFULL

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

    Nice explanation

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

    Clean explanation!👏

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

    Tysm😊

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

    Very good explanation :D

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

    Thank you! Thats helpful!

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

    Thank you so much

  • @Usha-h1d
    @Usha-h1d 2 месяца назад +1

    Sir,do you have notes for JavaScript

  • @indian-shorts9215
    @indian-shorts9215 11 месяцев назад

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

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

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

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

    bro i love your content!!. Im a school student and my brother is a advocate, so he wants me to make a website (law firm web page) for himself so that he can receive more clients. Can u make a tutorial on that plz?? Or if u have made one plz share me the link

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

      I don't have a video where we build a full website together yet. I might do that in the future.

  • @admiralcasperr
    @admiralcasperr 11 месяцев назад +1

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

  • @alfonzo6320
    @alfonzo6320 11 месяцев назад +1

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

    • @BroCodez
      @BroCodez  11 месяцев назад +1

      That's the next video on promises

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

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

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

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

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

    0:52 tasks were complete! 💪💋!

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

      1:46

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

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

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

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

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

      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.

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

    bro i wanna know who r u

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

    JS is a joke!