### Check out a free preview of the full Test Your JavaScript Knowledge course

The "Numbers" Lesson is part of the full, Test Your JavaScript Knowledge course featured in this preview video. Here's what you'd learn in this lesson:

Lydia explains the behavior of the post-increment operator and pre-increment operator, as well as the difference between using the "==" and "===" operators. They also discuss the "isNaN" function and the "toString" method for numbers. The lesson concludes with a discussion on the "parseInt" and "parseFloat" functions and how to use the "toString" method with different radix values.

### Transcript from the "Numbers" Lesson

[00:00:00]

>> This one is an easy one, should be an easy one, while it's locked, when we have number 0. We increment it, we increment it again, and then we log number again. Is it 1 1 2, 1 2 2, 0 2 2, 0 1 2, or 1 1 0?

[00:00:19]

And the right answer here is 022, because first we have the number plus plus, so we post increment it. So it will first return the value and then increment it, so that's still 0, but it has incremented in the background, it just doesn't log that yet. Then we have plus plus number, in which case it will increment it and then return it, so it goes from 1 to 2 and then we log it.

[00:00:41]

And then on the fourth line, we just log it again without doing anything, so it's 0 to 2. Just important to remember that using plus plus after a value will return the current value before incrementing it and using it before it will already return that increment value. Yeah.

[00:00:59]

Hello. Okay, just pretend you didn't see that, my laptop is just crashing. All right, well, what gets logged? So we have a is 3, b is a new number 3, and then c is 3 again. And then a == b, b == c, and a.toString = b.toString. And our answer here is true, false, false, true.

[00:01:30]

So whenever we have a number, or like the two equal signs is, not strictly equal, so in that case, it kind of coerces it to that new number. What's it called? Constructor to equalize it, in which case, it's true. The second one, there's a difference between using the new number constructor and having an actual integer.

[00:01:53]

So in this case, we have 3 and that new number 3. Well, they aren't strictly equal, so that is false, b shouldn't be equal to c. I think that one should be false as well. But what is true is d. We can use methods on numbers to string and everything that's usually only available on a new number constructor because JavaScript quickly wraps the number in a new number constructor when we use methods like that.

[00:02:19]

But after using it, it gets rid of that constructor again. Not that this is super important, but that's just something to remember. When you're using numbers, we can use all the methods of the new number constructor as well, because JavaScript just quickly wraps it in the constructor and then omits it again.

[00:02:33]

So we're using a set of number, and we have a couple of values here that we're analyzing. And what is the, or what gets logged? Is it all true? Is it all false? Or is it a combination? All right, the right answer here is false, true, true, true.

[00:02:52]

So what's happening here is that we have the is not a number function, and that just checks if the argument that we pass to it is the value not a number. So first, we have 5.2 plus 2 is 5.22, so it's not a number, it's false. But then we do parseInt a, so parseInt false, but we cannot parseInt, something that's not an integer.

[00:03:14]

So then parseInt throws not a number, we can't do that, so it's not a number is true. Same with parseFloat. That's the same for parseInt, we cannot do that because it's not a number, so it's true. isNaN is not a number, we have the string 1 times 2 times 2.

[00:03:30]

Well, we cannot, 1 times 2 is not a number, and we're trying to multiply that by 2, so that will also throw not a number, it's not a number, it's true. Just important to remember here that is not a number checks if it's actually the value not a number and not just a string or something.

[00:03:49]

All right, match the equivalent values. So we have ff, we have 101, we have SyntaxError and 255, and then some two string methods that will all return or some of them will return these values. Which of them will match the equivalent values? All right, the answer here is already A, B, C, D, it was correct as it was.

[00:04:12]

So first, we have the two stringing 16. So the two stringing method can or accepts a radix argument, and that just tells us the base with which one a string of five number. And we have binary, we have octal, we have decimal, and then hexadecimal. And this just changes how that string or how that number is made into a string.

[00:04:35]

So with the hexadecimal, we get the x value. So in this case, 255 is ff, it's like on the 16th value. Then we have binary and 255 and binary is just a times 1. 255.toString, it throws a syntax error because we're using a dot. And then you will see that we cannot do that, it's unexpected, because it thinks that this is a decimal.

[00:05:00]

So it needs to add another dot here, and then it'll be 255. And that's essentially what we did here, right, two dots. But you can just invoke the two string method with the bracket notation and use 10, and 10 is just like the default. Yeah, that's just the normal base.

[00:05:17]

So in this case, 255 is just turned into toString. We didn't have to specify the 10 here, it could have just been without 10 and would have returned the same value. But just remember that you have to use double dots if we wanna stringify a number.

### Learn Straight from the Experts Who Shape the Modern Web

- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops