Check out a free preview of the full Functional-Light JavaScript, v3 course

The "Level of Confidence" Lesson is part of the full, Functional-Light JavaScript, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Kyle analyzes the best way to evaluate the purity of a function, which is to look for areas where the programmer has high confidence, and ones where the programmer has low confidence.

Preview
Close

Transcript from the "Level of Confidence" Lesson

[00:00:00]
>> Kyle Simpson: What I'm getting at here is that function purity is a level of confidence, it's not a binary characteristic. Over the break I was asked by someone, what if there was a syntax that we could say, this thing is definitely pure and it threw errors, or not? And that's missing the point of JavaScript and the point of function purity.

[00:00:21]
Because the point of it in JavaScript is how confident are we the reader in its behavior? In other words, from here on out in our discussions, when I ask you the question, is this thing a pure function or not? The wrong answer is yes or no cuz it's not a binary question.

[00:00:44]
The right answer is I have a high degree of confidence that it will behave pure. Or I don't have very much confidence that it will behave pure, that's really what we wanna get. So we wanna be able to get those sunglasses on so that when we look at our code, we see that.

[00:01:01]
We see the parts where we have high degree of confidence, and we see the parts where we have low degree of confidence. And we wanna shift that balance as much as possible to the high degree of confidence. That is the heart of functional programming, using pure functions as much as possible.

[00:01:23]
>> Kyle Simpson: And remember, these are calls, not function definitions. What's important is the function call behaves pure or doesn't behave pure.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now