ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

What are Pure Functions? | Javascript Functions Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGra...
    What are Pure Functions? In this Javascript Functions tutorial, you will learn what pure functions are, how to code pure functions, and how pure functions will help your code be clean, easier to test, and easier to debug.
    🚩 Subscribe ➜ bit.ly/3nGHmNn
    🚀 JavaScript for Beginners: Full Course (8 hours): • JavaScript Full Course...
    🔗 Javascript Shallow Copy vs Deep Copy Tutorial: • Shallow Copy and Deep ...
    🔗 Javascript Higher Order Functions Tutorial: • Higher Order Functions...
    What are Pure Functions? | Javascript Functions Tutorial
    (00:00) Intro
    (0:15) What are pure functions?
    (0:26) Why write pure functions?
    (0:58) Rules for pure functions
    (1:36) A look at Rule #1
    (3:15) Always provide at least one parameter
    (4:02) A look at Rule #2
    (6:08) Impure function examples
    (8:43) Refactoring to pure functions
    (11:58) Higher Order Functions
    (14:05) Review of Pure Functions
    📚 References:
    "What Is a Pure Function in Javascript?"
    www.freecodeca...
    "What is a Pure Function?"
    / master-the-javascript-...
    "So You Want to Be a Functional Programmer (Part I)"
    / so-you-want-to-be-a-fu...
    ✅ Follow Me:
    Twitter: / yesdavidgray
    LinkedIn: / davidagray
    Blog: yesdavidgray.com
    Reddit: / daveoneleven
    Was this tutorial about Pure Functions in Javascript helpful? If so, please share. Let me know your thoughts in the comments.
    #pure #functions #javascript

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

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  3 ปีที่แล้ว +3

    This tutorial will explain what pure functions are, how to write them, and why you should. A concept from functional programming, pure functions will keep your code clean, make it easy to test, and likewise, make it easier to debug. There are just a couple of rules for pure functions. I'll cover those and provide several examples along the way. If you are just beginning to learn Javascript, I suggest starting with my full 8 hour course tutorial here: th-cam.com/video/EfAl9bwzVZk/w-d-xo.html 🚀

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

    Yours are some of the clearest and most useful JS tutorials on TH-cam. Bummer it's hard to gain views with such advanced topics, but this makes your hard work just more valuable! Big respect.

  • @shamoozoid
    @shamoozoid 2 หลายเดือนก่อน

    Wow, 1st video on JavaScript functions that I have come across that is not a person speaking broken English. It is hard enough to learn without having to decipher what the person is trying to say.

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

    This is the greatest JavaScript channel i could ask for. Your clear explanation of all of these JS concepts are incredibly helpful. Thank you so much for this content!

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

    Today I have the "Dave Gray's video evening". One after another. And all of them are very informative and very easy to listen and absorb. 👉🏼🔥

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

    You are the best man!
    Whenever I want something advanced or to get an idea in depth I check if you have it on your channel first! It's like your channel is becoming my bible

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

    Awesome video Dave! I love functional programming and have been playing with the idea of making a video about currying.

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

      Thanks Tom! 🙏 I was thinking about that topic as my next, too. I think you should also make one. I'll check it out ☑️💯

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

    Awesome content sir. Needed to brush up my memory on these small but yet important topics

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

    You made the subject so pleasurable to follow, straight to the facts. Helping my favorite mentor to make it more to the YT algorithm, one comment at a time :)

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

    Rewatching this was a pleasure :)

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

    Great video thanks Dave Sir.
    Namaste from India.❤️🙏

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

      You're welcome! 🙏💯

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

      @@DaveGrayTeachesCode ☺️☺️☺️🙏🙏

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

    Thanks!
    Seems quite important concept (...which requires a lot of practice).

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

    Thank you so much for this video! I always read that pure functions should not have any side effects, but never understood the meaning.

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

    thank you very much for this info bro! SO helpful!

  • @gordonmullen7272
    @gordonmullen7272 3 ปีที่แล้ว

    Thanks again Dave for the "DETAIL", it really really helps. And thanks on the MVC advice, downloaded an app with a OOP version and then one with a functional version and it really brought some insight of the inner workings of both. You have a way to help support your work there? again, thanks so much!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 ปีที่แล้ว

      You're welcome! I appreciate the kind words. And thanks for asking. This summer I plan to look into a Patreon and hopefully launch an email, too. 🙏💯

  • @user-hg8bo3em5y
    @user-hg8bo3em5y 2 ปีที่แล้ว

    Very concise and informative, thank you sincerely!

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

    Awesome job man! this is the best tutorial about this subject!

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

    @DaveGray a great tutorial and such a great playlist. but i have one question/correction timestamp 7:23. i think increment function doesn't break rule #3 which is mutating a variable because increment function is just assigning a value to x not mutating it and also primitive variables are immutable

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

      That increment function is not taking any parameters. It is changing the value of globally assigned variable x.

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

      Assigning a value also a kind of mutation.

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

    Amazing tutorial. Thank you for making high quality contents!!

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

    Great Video... HATS OFF

  • @joynal_dev
    @joynal_dev 3 ปีที่แล้ว

    Great video. Learned a lot.

  • @tedndg
    @tedndg 3 ปีที่แล้ว

    great explanation

  • @viniciusm.m.7822
    @viniciusm.m.7822 3 ปีที่แล้ว

    Thanks a lot!

  • @doniaelfouly4142
    @doniaelfouly4142 3 หลายเดือนก่อน

    thanks

  • @aliciapeter562
    @aliciapeter562 3 ปีที่แล้ว

    Thanks Dave . Keep going PLS :]

  • @Johnny-rn8fb
    @Johnny-rn8fb ปีที่แล้ว

    Amazing

  • @1dforever952
    @1dforever952 ปีที่แล้ว

    Hi, Kindly try to upload the code in a GitHub repository. I Don't Know If you have a GitHub repository for this tutorial. But try to upload the code for other tutorials. Thank you for making this content! Big respect.

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

      Thanks for the request! For some of these short tutorials, I encourage viewers to simply recreate the examples as I go.

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

    If a function not returning something means automatically it returns a undefined value. In this case it's not pure function? What if I explicitly return undefined?

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

      That's a good question! If you stick with the rules of Pure Functions... Does the same input always produce the same output? Are there no side effects? If it meets those expectations, it is considered Pure.

  • @doniaelfouly4142
    @doniaelfouly4142 3 หลายเดือนก่อน

    thanks