Error First Callback Patterns in JS

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 8

  • @oah8465
    @oah8465 2 роки тому +2

    This content is out of this world. Thx a ton professor.

  • @CodingNuggets
    @CodingNuggets 3 роки тому +2

    You are always putting out such good quality content. I'm a fan. Thanks Steve. See you soon!

  • @ProfessorSyndicateFranklai
    @ProfessorSyndicateFranklai 3 роки тому

    I think js especially benefits from this pattern, at least in the way I use it, due to the fast and loose way it plays with types. In your browser example, it's seems that there would be no need for checking if value passed is a string if the language had stricter typing (though it still may be necessary to check for null).
    At some level, ensuring the integrity of values passed cannot be the responsibility of the language itself, but I can say that after programming in JS for so long the first thing I missed was stricter typing. Though, I wouldn't trade creating objects and adding properties so easily for any other language.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 роки тому

      The example in the video of type checking was just a simple example for people to understand how the process works.
      There is less and less use of this pattern in new code thanks to support for Promises but still useful to know.

  • @prinzadamz
    @prinzadamz Рік тому

    Thanks man 👍👍❤❤

  • @mostafagh3573
    @mostafagh3573 2 роки тому

    amazing, thank u sir

  • @aaron10k
    @aaron10k Рік тому

    Something im really confused about is how are err/data passed into the callback function? I mean, they aren't defined/dont exist before it is called, so how can we pass them into the function to use them?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Рік тому

      In this example, it is the readFile method that calls the callback function and passes in the error object and/or data.
      Just like the Array.map( ) method accepts a function as an argument. When the map method calls that function, it is the map method that passes in the value, index, and array reference.
      ua-cam.com/video/uPCxgnLOuiQ/v-deo.html
      ua-cam.com/video/DxWqsNMccHY/v-deo.html