JSBits #4: Comparison operator

Diario del capitán, fecha estelar 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 tuvo un Oric 1 como primer ordenador, al menos hace 100 años. Ahora combina la programación con sus dos bandas y sus tres hijos. La leyenda dice que tiene un hermano gemelo idéntico y que trabajan como equipo.

comments powered by Disqus

Estás a un paso de conocer a tu mejor socio.