The best way to learn how to write code is to write code.

— Kyle Simpson

At the beginning of my career as a JavaScript Developer, I thought it’s not a bad thing to avoid learning how does that technology work under the hood. That seems to work, but in the end, my code was buggy.

One of the main things you have to understand is coercion. All I had ever heard about coercion is in blogs and books which rarely refer to the documentation.

Today, I know that only a valid source is documentation. At the end that’s a logic thing because who knows better programming language than a person who creates it?


Strict and Abstract Equality have things in common

I always like to visualize things so I’ll give a simple example:

I have a string "Jonny" that is attached to a variable name1. I could create a copy of the name1 and attach it to name2. So when I check strict and abstract equality both return the same - true.

It turns out that when types match triple equals is called by the system. Strict and loose equals are both equal when types are identical. Absolute no difference in this case!

Null and undefined have a lot of things in common

I won’t give you any information before I give a reference. As I previously said, the only legitimate source is docs:

Abstract Equality Comparison in JavaScript

Abstract Equality Comparison (source: ECMAScript Standard)

If we decide to compare _null _and _undefined _with loose equals, we’ll get true since null and undefined are coercively equal to only each other:

#javascript #programming #programming-tips #javascript-development #javascript-tips

How does Abstract Equality Comparison work?
1.25 GEEK