JavaScript Pure Functions - Tutorial for beginners
Ғылым және технология
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/shop/ColorCodeStore
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.io/js-mastery
Пікірлер: 143
Episode 16: Pure Functions 🤘👨💻🔥🎉
@sergiu6650
3 ай бұрын
Well done .. Craig!, Can you post more often ? :D Maybe some React stuff ?
The song: counting bodies like sheep to the rhythm of the wardrums Performed by: a perfect circle I love your music references. 👍
@ColorCodeio
3 ай бұрын
Correct! Nice job
Javascript legend 🎉👍
Oh man, we need a video editing tutorial as well 😛🤩
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
22 күн бұрын
I appreciate that!
Honey, wake up. ColorCode posted a new JavaScript video.
@ColorCodeio
2 ай бұрын
haha ♥
Sina I LOVE your way of teaching, it's just so simple, entertaining and helpful
@ColorCodeio
2 ай бұрын
Thank you!
Bro thanks... The way you break down the entire language is awesome.
You know you have the perfect combo. The videos are both interesting and useful.
@ColorCodeio
2 ай бұрын
I appreciate that!
...when you find out your nascent skillset/hobby comes with a KZreadr 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]
Love your style of video editing and how you present the concepts in such a fun way! You deserve much much more subscribers!
So happy to found your channel, it makes my frontend developer study journey so much better! Cheers
@ColorCodeio
2 ай бұрын
Cheers!
Welcome back with long waiting videos. Please continue. 😀
@ColorCodeio
2 ай бұрын
Will do!
Intro and editing was on the next level 💥💥💥💥
Best conceptual coding videos ❤
@ColorCodeio
3 ай бұрын
🕺🏻
Best content for understanding difficullt javascript concepts! Thankyou
Hats off to you, nice to have you back.
@ColorCodeio
2 ай бұрын
♥
man you are the best at acting and explaining complex stuff for me, i really enjoy your videos
@ColorCodeio
22 күн бұрын
Glad you like them!
Brief, simple, clear and fun. Thanks for this amazing learning material
@ColorCodeio
3 ай бұрын
🤘🏼👍🏼
This video should be a preparatory course for React beginners 😏
@ColorCodeio
2 ай бұрын
I agree
My favourite online coding teacher is back
@ColorCodeio
2 ай бұрын
♥🙏
Best. Intro. Ever. ❤
@ColorCodeio
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
3 ай бұрын
Great suggestion!
Love you soo much your tutorials are first class
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
2 ай бұрын
Awesome. Thanks!
great video as always. i think that you should address that functional programming is often about higher order functions and state separation
We need consistent videos from Sin Jazzz 🎉
Alright, im ready for the next video, keep em coming!
@ColorCodeio
2 ай бұрын
Soon
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
2 ай бұрын
Thank you! Coming soon
Thank you sinaaaa ❤
@ColorCodeio
2 ай бұрын
♥🙏
I am in Love with your explanations Bro. It's Amazing.
@ColorCodeio
2 ай бұрын
Tysm!
Someone has been watching "Succession" hahaha hahahaha. Thanks a lot Sina, your content never let me down. Cheers!!
@ColorCodeio
2 ай бұрын
Thank you! Good show.
Nice one! ❤
hey, I love your teaching style. please make a video on Garbage collection and circular referenced objects.
Your videos are really great ❤ thankyou. I request you plz do videos on React Hooks
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
@ColorCodeio
2 ай бұрын
Yes!
Your edits are awesome
@ColorCodeio
2 ай бұрын
Ty!
One reason I love typescript. It catches a lot of this
Such a wonderful tutorial ❤ Would you do an episode about design patterns and maybe software testing in the future?
@ColorCodeio
22 күн бұрын
Good ideas
Welcomeee baaack🔥🔥🔥🔥
@ColorCodeio
3 ай бұрын
🙏🏼
Thank You for this video. ❤
@ColorCodeio
2 ай бұрын
You're welcome
Thank you for your efforts
@ColorCodeio
2 ай бұрын
You're most welcome
Pure presentation of Pure func👍👍
The best tutorials.
@ColorCodeio
2 ай бұрын
Ty!
So creative representation.
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
3 ай бұрын
Comment of the year 🏆
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.
I was hapoy to see you in my notification panel
Great Job Sina! Amazing content.👑 Kindly post react content as well
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 ♥😍😍
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
3 ай бұрын
Salut tot din Romania.
@ColorCodeio
3 ай бұрын
Hello Romania! 🇷🇴
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
Been waiting so long for this series to continues! So glad that your back!
@ColorCodeio
2 ай бұрын
Ty!
The inventor of fun JavaScript:
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
3 ай бұрын
Absolutely correct
I been waiting since long 😭😭😭😭
Javascript legend is back 🥳🥳🥳🥳🥳🥳🥳🥳🥳🥳
@ColorCodeio
3 ай бұрын
🕺🏻🙇🏻♂️
I hope we get a "Qoli" face reveal by Episode 20 :) Awesome video man!
@ColorCodeio
2 ай бұрын
It's a possibility 🤨
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
2 ай бұрын
It's called RunJS - Here's my affiliate link: runjs.app/colorcode
@puyakhalili
2 ай бұрын
@@ColorCodeio Wow incredible! Thanks Sina :) BTW I love the Gholi cameos in your videos! Our beloved childhood friend ;)
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
2 ай бұрын
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.
Waiting ... && ❤❤❤🎉🎉🎉
Really curious, what is the tool you are using for the live coding? Looks useful, particularly for learning / testing ideas.
@ColorCodeio
2 ай бұрын
It's called RunJS. Here's my affiliate link: runjs.app/colorcode
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
2 ай бұрын
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
2 ай бұрын
@@ColorCodeioAh ok! Thanks! :D
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
22 күн бұрын
www.warbyparker.com/eyeglasses/dawson/azure-crystal-with-oak-barrel
Finally 🎉🎉🎉🎉🎉
@ColorCodeio
2 ай бұрын
🎉
Rule 1 : one-to-one relation
when is your course dropping ? cant wait!
@ColorCodeio
2 ай бұрын
Working on it as we speak. Make sure you join the list on www.colorcode.io
GOAT!
@ColorCodeio
2 ай бұрын
🐐
wooooooohoooo you da best :))))
@ColorCodeio
2 ай бұрын
So are you
Hi, Please let me know how to use spotlight effect on Mac mouse, thanks!
@ColorCodeio
2 ай бұрын
boinx.com/mousepose/
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
2 ай бұрын
RunJS.app/ColorCode
He actuallyt made me drink water.. thanks yo
@ColorCodeio
3 ай бұрын
Stay hydrated! 🚰
Can you please do a video about side effect?
@ColorCodeio
3 ай бұрын
I cover side effects in this video
I came looking for copper and found gold
what code editor you are using? i want that simplicity
@ColorCodeio
2 ай бұрын
RunJS.app/ColorCode
hello, what font do you use ?
@ColorCodeio
2 ай бұрын
monaco
Extension for console??
@ColorCodeio
3 ай бұрын
RunJS.app/ColorCode
aleluya! hehe
"JavaScript MasterClass Available Spring 2023" ...
where is ur podcast :(
@ColorCodeio
2 ай бұрын
After the full JS course
Are you a syrian living in turkey ?
@logicmonster6197
3 ай бұрын
Bro he is definitely an Indian American
@ColorCodeio
2 ай бұрын
Neither
salut('Logan') never can be a pure function! It can unexpectedly return "Fu*k off" :))
Your videos are absolutely 🔥. Dude, dope a$$ jacket 🫡
@ColorCodeio
2 ай бұрын
Thanks! 🤘
The inventor of fun JavaScript: