JSBits #4: Comparison operator

Captain's log, stardate d71.y38/AB

Here's another JavaScript bits we wanted to share with you. Let's talk about the comparison operator, today!

Pen with mathematical formulae - Photo by Antoine Dautry on Unsplash

Just in case you don't know it, JavaScript has two different operators to compare primitives (neither of them works with objects, though). One is == (equality) and the other is === (identity).

If you have to know only one thing is don't use == never, ever. There's always a better, safer and more performant alternative using ===.

If you want to learn more, read this StackOverflow entry.

Daniel Gómez

Daniel Gómez

Dani started playing with computers with his Oric 1, at least 100 years ago. He now juggles his programming skills with two bands and being a father of three. Legend says, it's him and his identical twin brothers working as a team.

comments powered by Disqus

You're one step away from meeting your best partner in business.

Hire Us