Blog Post

Some Zombies Are More Equal Than Others

How can things be more or less equal (outside of Animal Farm)? This is because of one way that a computer saves memory. Our bucket metaphor will break down a bit here, but let’s say we had a bucket full of something complex, such as a loaf of bread. There’s a lot of information there. It’s complex, and it takes up space.

The human resistance commander needs to see what rations are available, but he’s in the field with the resistance fighters. We could create a copy or 3-D model of the bread (super easy in this computer-i-fied example), but that would take up as much space as the original, and we might run out of buckets. We’d also have to transport the bread or model out to him, which can get complicated when you have quite a few buckets to transport.

So we take a picture of the bread instead. In very general terms, the loaf and the picture are equivalent because one is the loaf and one points to or is a picture of that same loaf. (In computer science, the picture from our analogy is called a pointer because it “points” to the original.) That’s the double equals == level of equality. The triple equals === is when you’re trying to see if two loaves of bread are the same or, rather, if one of them isn’t a pointer to/picture of the other.

In code, a simplified version of that might look like

7 == “7//true
7 === “7//falseCode language: JavaScript (javascript)