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

JavaScript Pure Functions - Tutorial for beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2024
  • Pure Functions are an essential ingredient of functional programming, regardless of the language. In this video we cover the two major rules that make any function pure, benefits of pure function, as well as why some functions can't be pure. Let's have some fun yo!
    This is episode 16 of 20 things Javascript Developers Should Know But Probably Don't.
    00:00:00 Intro
    00:01:15 What is a pure function?
    00:01:52 Rule #1: Same input means same output
    00:02:58 🔴 Live coding: Rule #1
    00:08:37 Benefits of Rule #1
    00:10:04 Testability
    00:12:05 Rule #2: No side-effects
    00:12:22 🔴 Live coding: Rule #2
    00:15:07 Benefits of Rule #2
    00:16:40 Impure functions 😱
    00:18:17 Outro
    ColorCode Etsy Merchandise store:
    www.etsy.com/s...
    Full playlist here: • 20 Things JavaScript D...
    JavaScript Promises from the series "20 Things JS Developers Should Know but Probably Don't"
    by ColorCode.io, Sina Jazayeri
    ** Announcement **
    Full JavaScript Mastery course is coming! Sign up for Early Access here:
    www.colorcode....

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

  • @ColorCodeio
    @ColorCodeio  6 หลายเดือนก่อน +29

    Episode 16: Pure Functions 🤘👨‍💻🔥🎉

    • @sergiu6650
      @sergiu6650 6 หลายเดือนก่อน +3

      Well done .. Craig!, Can you post more often ? :D Maybe some React stuff ?

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

    Honey, wake up. ColorCode posted a new JavaScript video.

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

      haha ♥

  • @zero11010
    @zero11010 6 หลายเดือนก่อน +12

    The song: counting bodies like sheep to the rhythm of the wardrums
    Performed by: a perfect circle
    I love your music references. 👍

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน +2

      Correct! Nice job

  • @javeedakhter324
    @javeedakhter324 6 หลายเดือนก่อน +15

    Javascript legend 🎉👍

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

    Oh man, we need a video editing tutorial as well 😛🤩

  • @cosmasdaniella2079
    @cosmasdaniella2079 24 วันที่ผ่านมา +1

    I don't know why I am just discovering your channel, but I am so glad I did. You are a great tutor.🔥🔥

    • @ColorCodeio
      @ColorCodeio  19 วันที่ผ่านมา

      Thank you!

  • @JohnnyDiabetes
    @JohnnyDiabetes 4 หลายเดือนก่อน +1

    ...when you find out your nascent skillset/hobby comes with a TH-camr that makes incredible content with clarity, humor, style, and beauty. And you just wish you could make him understand how much you appreciate him...
    Thank you, Sina. You're like that indie film that is so special that you want everyone to see it and love it as much as you do. You're my developer-resource version of 'Sing Street' (2016). Or maybe 'You Can Count On Me' (2000).
    [digital gratitude hug]

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

      Thank you for the love, Johnny! Made my day. Great comment.

  • @beinyourguard
    @beinyourguard 6 หลายเดือนก่อน +5

    Sina I LOVE your way of teaching, it's just so simple, entertaining and helpful

    • @ColorCodeio
      @ColorCodeio  5 หลายเดือนก่อน +2

      Thank you!

  • @4rmboy666
    @4rmboy666 6 หลายเดือนก่อน +5

    You know you have the perfect combo. The videos are both interesting and useful.

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

      I appreciate that!

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

    i been browsing advanced Js tutorials all around, i got few but sounds boring, i really appreciate the energy you got while explain things, totally love it, can't wait for more content.

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

      I appreciate that!

  • @mikeJohnson2222
    @mikeJohnson2222 5 หลายเดือนก่อน +2

    Bro thanks... The way you break down the entire language is awesome.

  • @nirau
    @nirau 5 หลายเดือนก่อน +3

    So happy to found your channel, it makes my frontend developer study journey so much better! Cheers

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

      Cheers!

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

    Brief, simple, clear and fun.
    Thanks for this amazing learning material

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน +2

      🤘🏼👍🏼

  • @amsxiety
    @amsxiety 6 หลายเดือนก่อน +4

    Best conceptual coding videos ❤

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

      🕺🏻

  • @sugarfairy1248
    @sugarfairy1248 4 หลายเดือนก่อน +1

    Love your style of video editing and how you present the concepts in such a fun way! You deserve much much more subscribers!

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

      Thank you!

  • @krypton_dev
    @krypton_dev 6 หลายเดือนก่อน +3

    Thank you sinaaaa ❤

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

      ♥🙏

  • @BigBabyofTel
    @BigBabyofTel 6 หลายเดือนก่อน +2

    Your style of teaching is effective. I hope you get the energy to do something similar with Typescript. This series on JS is already one of the best ones on YT

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

      Great suggestion!

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

    great video as always. i think that you should address that functional programming is often about higher order functions and state separation

  • @Tarek_Abdelhafez
    @Tarek_Abdelhafez 6 หลายเดือนก่อน +3

    Welcome back with long waiting videos. Please continue. 😀

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

      Will do!

  • @jonathanserwano9948
    @jonathanserwano9948 4 หลายเดือนก่อน +1

    man you are the best at acting and explaining complex stuff for me, i really enjoy your videos

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

      Glad you like them!

  • @hessamt800
    @hessamt800 6 หลายเดือนก่อน +2

    Hats off to you, nice to have you back.

  • @NikolayVeselinov
    @NikolayVeselinov 6 หลายเดือนก่อน +2

    Alright, im ready for the next video, keep em coming!

  • @opsingh861
    @opsingh861 3 หลายเดือนก่อน +1

    Intro and editing was on the next level 💥💥💥💥

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

      Appreciate it!

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

    You’ve explained pure functions in a way that I finally understand! 🎉 Thank you! 🙏🏼
    Loving this whole series ❤ I found it searching for the Fetch API and have been back to watch the whole series 👌🏻

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

      Awesome. Thanks!

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

    hey, I love your teaching style. please make a video on Garbage collection and circular referenced objects.

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

    Your videos are really great ❤ thankyou.
    I request you plz do videos on React Hooks

  • @divineamos3296
    @divineamos3296 27 วันที่ผ่านมา

    You can't believe how good this tutorials are!

    • @ColorCodeio
      @ColorCodeio  24 วันที่ผ่านมา

      Thank you!

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

    Also the no side effects is so important in state management and the core concept of libraries like redux. Never modify state directly. Only return an updated state

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

    I am in Love with your explanations Bro. It's Amazing.

  • @davidag90
    @davidag90 6 หลายเดือนก่อน +2

    Someone has been watching "Succession" hahaha hahahaha. Thanks a lot Sina, your content never let me down. Cheers!!

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

      Thank you! Good show.

  • @sam_6480
    @sam_6480 4 หลายเดือนก่อน +1

    Such a wonderful tutorial ❤ Would you do an episode about design patterns and maybe software testing in the future?

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

      Good ideas

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

    Thank you so much! This is pure and simple to understand! Nice haircut! SO SO SO Looking forward to the next episode!!! Thank you again!!!!

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

      Thank you! Coming soon

  • @hollam224
    @hollam224 4 หลายเดือนก่อน +1

    Love you soo much
    your tutorials are first class

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

      Thank you so much!

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

    My favourite online coding teacher is back

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

      ♥🙏

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

    We need consistent videos from Sin Jazzz 🎉

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

    Been waiting so long for this series to continues! So glad that your back!

  • @himalayanmonk3350
    @himalayanmonk3350 2 หลายเดือนก่อน +1

    Good sir , you are a gentleman and a scholar ❤

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

    Your edits are awesome

  • @Thassalocracy
    @Thassalocracy 6 หลายเดือนก่อน +2

    This video should be a preparatory course for React beginners 😏

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

      I agree

  • @RostyslavNazarenko
    @RostyslavNazarenko 4 หลายเดือนก่อน

    Can we have a video in unit testing? But I'll probably learn it by myself till then) but I love your videos and type of teaching, and of course, I love you ♥😍😍

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

    Thank you for your efforts

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

      You're most welcome

  • @mehmedshehov302
    @mehmedshehov302 9 วันที่ผ่านมา

    Very nice video, just a small tip from me. It will be better if you keep the background music one notch down

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

    Great Job Sina! Amazing content.👑 Kindly post react content as well

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

    The best tutorials.

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

    Thank You for this video. ❤

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

      You're welcome

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

    Best content for understanding difficullt javascript concepts! Thankyou

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

    Hi Sina, amazing work bro
    I would like to suggest this topics for future videos:
    💎 Getters and Setters
    💎 Short circuit operator
    💎 Event Propagation
    Thanks for the quality of the content, greetings from Colombia

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

    It can be argued that a function executing a console.log is an impure function, as its side-effect is writing to the console.

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน

      Absolutely correct

  • @creed_forever
    @creed_forever 4 หลายเดือนก่อน +1

    So creative representation.

  • @ianfrye8988
    @ianfrye8988 6 หลายเดือนก่อน

    One reason I love typescript. It catches a lot of this

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

    I was hapoy to see you in my notification panel

  • @davidvernon3119
    @davidvernon3119 6 หลายเดือนก่อน

    Great video, great singing. I would add that while you can write pure functions in JavaScript, the language doesn’t support them the way some fancier languages do. For example in rust all functions are pure by default and the compiler guarantees this and you have to declare your intentions to be impure (to sin) by including self as an argument.

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

    Pure presentation of Pure func👍👍

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

    Nice one! ❤

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

    Best. Intro. Ever. ❤

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

    Salut to you as well, from Romania. Great series, my dude. You could fit right into a real brick-and-mortar University as a cool JS teacher.

    • @sergiu6650
      @sergiu6650 6 หลายเดือนก่อน

      Salut tot din Romania.

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

      Hello Romania! 🇷🇴

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

    Coding fact: If you write a function that sets the CSS variable for Sina's hair to 'hidden' and attach an onClick, you can transform him into Stanley Tucci. Add a 0.5s ease-in-out for a smoother transition.
    This is based purely on the thumbnail to this video btw..

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน

      Comment of the year 🏆

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

    I hope we get a "Qoli" face reveal by Episode 20 :)
    Awesome video man!

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

      It's a possibility 🤨

  • @denisveli9465
    @denisveli9465 3 หลายเดือนก่อน +1

    Thank you for the amazing content!
    Sorry about the awkward questions but I really like you glasses. Could you tell me the brand and the model, please?
    Thank in advance and keep up with the videos you're doing!

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

      www.warbyparker.com/eyeglasses/dawson/azure-crystal-with-oak-barrel

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

    Welcomeee baaack🔥🔥🔥🔥

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน

      🙏🏼

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

    You deserve a lot more credits for your videos. ;)
    Anyway, may I ask a video about the semi colon? Is it good, is it bad, why was removed... :D

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

      I don't use them in these tutorials just to make things a little cleaner, and it doesn't really have an impact with some rare exceptions in return statements

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

      @@ColorCodeioAh ok! Thanks! :D

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

    Sir you’re an amazing teacher. I aspire to be as clear and concise with my videos as you are. May I ask how you do you color grade your videos (lut or preset?) bc they’re beautiful. Also how do you edit your self right beside your editor? Is it a template for your screen recording or editing software?

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

      It's got more to do with lighting and a good lens than software. Watch some tutorials on lighting before getting into LUTs, then you can do color correction based on your environment.

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

    Really curious, what is the tool you are using for the live coding? Looks useful, particularly for learning / testing ideas.

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

      It's called RunJS. Here's my affiliate link: runjs.app/colorcode

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

    Thank you 🐐

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

    The inventor of fun JavaScript:

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

    Javascript legend is back 🥳🥳🥳🥳🥳🥳🥳🥳🥳🥳

    • @ColorCodeio
      @ColorCodeio  6 หลายเดือนก่อน

      🕺🏻🙇🏻‍♂️

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

    I been waiting since long 😭😭😭😭

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

    when is your course dropping ? cant wait!

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

      Working on it as we speak. Make sure you join the list on www.colorcode.io

  • @creed_forever
    @creed_forever 4 หลายเดือนก่อน

    Rule 1 : one-to-one relation

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

    GOAT!

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

    Finally 🎉🎉🎉🎉🎉

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

    Hey Sina! Wonderful video can youu tell me which editing software you use to edit your videos? Wow come on man sick editing!

    • @ColorCodeio
      @ColorCodeio  24 วันที่ผ่านมา

      Final Cut Pro + Apple Motion

    • @PhantomDeluxe1111
      @PhantomDeluxe1111 24 วันที่ผ่านมา

      @@ColorCodeio oh thank you Sina and can you make a video on expression and statements like a full video becz It is very confusing and I would be pleased to see u upload one, thank you in advance😅😄😄🙂

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

    Amazing video thanks a lot Sina. BTW how do you get the code continuously running on the right pane? is that Quokka ? and how do you get it to run in a separate column?

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

      It's called RunJS - Here's my affiliate link: runjs.app/colorcode

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

      @@ColorCodeio Wow incredible! Thanks Sina :) BTW I love the Gholi cameos in your videos! Our beloved childhood friend ;)

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

    wooooooohoooo you da best :))))

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

      So are you

  • @shahidshafi1227
    @shahidshafi1227 6 หลายเดือนก่อน +2

    Extension for console??

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

      RunJS.app/ColorCode

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

    Waiting ... && ❤❤❤🎉🎉🎉

  • @user-vo8hn7yj7z
    @user-vo8hn7yj7z 6 หลายเดือนก่อน

    Hi, Please let me know how to use spotlight effect on Mac mouse, thanks!

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

      boinx.com/mousepose/

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

    Starting at 3:00, how do you access this clear code editing space in the browser? Which browser is it? How do I access this window? It’s so clean!

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

      RunJS.app/ColorCode

  • @shinigamiryoutaro
    @shinigamiryoutaro 6 หลายเดือนก่อน +2

    He actuallyt made me drink water.. thanks yo

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

      Stay hydrated! 🚰

  • @endfine9230
    @endfine9230 4 หลายเดือนก่อน

    I came looking for copper and found gold

  • @CLeovison
    @CLeovison 6 หลายเดือนก่อน

    Can you please do a video about side effect?

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

      I cover side effects in this video

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

    where is ur podcast :(

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

      After the full JS course

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

    what code editor you are using? i want that simplicity

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

      RunJS.app/ColorCode

  • @longingbydesign
    @longingbydesign 6 หลายเดือนก่อน

    "JavaScript
    MasterClass
    Available Spring 2023" ...

  • @copytopgrade6458
    @copytopgrade6458 6 หลายเดือนก่อน

    hello, what font do you use ?

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

    salut('Logan') never can be a pure function! It can unexpectedly return "Fu*k off" :))

  • @badr5465
    @badr5465 6 หลายเดือนก่อน

    aleluya! hehe

  • @djhi-tek9249
    @djhi-tek9249 6 หลายเดือนก่อน

    Are you a syrian living in turkey ?

    • @logicmonster6197
      @logicmonster6197 6 หลายเดือนก่อน

      Bro he is definitely an Indian American

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

      Neither

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

    Your videos are absolutely 🔥. Dude, dope a$$ jacket 🫡

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

      Thanks! 🤘

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

    The inventor of fun JavaScript: