ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
JavaScript Pure Functions and Side Effects in 8 Minutes
ฝัง
- เผยแพร่เมื่อ 16 ส.ค. 2024
- In this video, we'll be going over pure functions and side effects. I'll explain what they are, why it's important to understand them, show you some examples, and even quiz you on your new-found knowledge.
Though this isn't often seen as a "beginner" topic, I think it's really important to expose concepts like pure functions and side effects as early as possible so new developers can be enabled to not only developer interesting applications but do it in such a way that is clean and scalable.
Functions in JavaScript can serve a large number of different purposes. Pure functions aim to simplify and clarify the logic of your code. Side effects are byproducts of executing non-pure functions throughout your application
🎬 Subscribe to the channel! - / @ijemmaonwuzulike
Timestamps:
0:00 Intro
0:37 What is a Pure Function?
0:57 Same Input, Same Output
2:31 What is a Side Effect?
2:56 Side Effect - Directly Mutate Outer State
3:41 Side Effect - Mutate Method Arguments
5:16 How to Avoid Producing Side Effects
5:58 Quiz Time
== Let's Connect ==
🐦 Twitter - / ijemmaohno
== Who I Am ==
I'm Ijemma, a frontend software engineer currently working in New York City. I make videos on all things JavaScript and, more broadly, frontend web development.
#javascript #webdevelopment #softwareengineer
just found ur channel, amazing, and shoutout for the OP love.ur a good teacher
That was sooooo high quality! Keep it up dude, happily subscribed :D
Thank you so much, more is definitely on the way. lmk if you wanna see a topic covered!
Another high quality video! You're crushing it! A good followup would be some content around what's pure and what has side effects in the base language (e.g. Array.(map|reduce|etc.) vs Array.sort).
I love that idea 🤩I think relating these topics back to the base language really helps people understand the importance of them
Awesome video! :) Thank you!
I really enjoyed this topic and your explanation is great..... Dude.
May I know u r from which country...🙏🙏🙏
Great video, I love it! 💯
Video actually is very useful for beginners. But... Beginners don't think about these kind of things before they meet their own precious sufferings of side effects. So it will be better to show them those bugs on more "realistic" examples to send them into developer's catharsis))
lol developer's catharsis, I like the idea of showing realistic examples, I gotta keep that in mind for future videos 🙌🏾
Hi, just a small clarification. At 4:11 you said: "Arguments of methods are actually references to their original value.". Thought this is true in case of passing non-primitive values such as an Array or a user-defined object as an argument to a function but when primitives like number, boolean, etc are passed to a function then they are passed by value and not reference. Great content btw. :) Subscribed!
Also, at 6:09 in the quiz example shown. If the company name were to be declared as an object with a key companyName & some other impure function might change this object's property then how can we be sure that getIntroduction will always give the same output given the same set of inputs. Because if the variable companyName changes then the function getIntroduction does not know about it and now for the same input variable name we might get a new returned string which is different from the previous cached version!
oh that's a good catch, thanks for mentioning that!
+1 for examples referencing anime ⚓️
Ofc I had to lol