In last video we started talking about the fourth rule around reducers.
And we had added in a little bit more context to understanding exactly what the word mutate means in
javascript.
Now before you dive face first into this rule right.
One other quick side topic I just want to flip back over to my counsel over here very quickly.
One little thing I want to show you.
So inside of this little terminal I'm going to define a new array called numbers and I'll give it the
values 1 2 and 3.
Now you might know that inside of javascript we can very easily compare equality between two values
using the triple equals operator.
So for example I can say one equals equals equals 1 and that's going to return true.
Likewise I can do a string of high.
Equals equals equals high.
And that would turn true as well.
And of course if I do one not equals two we're gonna get True.
And 1 not equals 1 is going to be false because 1 and 1 are equal to each other.
Now this comparison operator can be used on arrays in objects as well.
So I can very easily say something like Does numbers equal or equal equal numbers like so and of course
that is true.
Now in the case of primitive values such as numbers and strings we can kind of imagine that this is
a value comparison.
In other words is the number one equal to the value of the number 1.
But how comparison is done around arrays and objects is a little bit more subtle.
You see when you use this triplet equals operator right here on an array javascript is checking to see
if it is a reference to the exact same array in memory not the contents of the array.
So for example if I say numbers numbers numbers equals a brand new array of 1 to 3 this is going to
return false because the comparison here is not between the contents of the array.
You'll notice those are identical.
The comparison is between whether or not numbers.
This variable right here is referencing the exact same array in memory as the one on the right hand
side this one over here.
In this case it is not.
We declared this array up here that is in some location in memory or RAM on your computer and then you
defined a completely new array down here.
So you now have two separate arrays inside of RAM or memory on your computer.
And so in this case these two separate arrays are clearly not the same array.
So when we do this comparison it's going to return a value false because no it's not the same array
in memory OK.
Now we understand that.
Let's take one more very brief pause.
I promised last pause here and then we come back we'll finish up on this rule.