Tipo de coerção
console.log(true + false); // 1
console.log(true + true + true); // 3
++++++++++++++++++++++++++++++++++++++++
console.log(1 + "1"); // "11"
console.log(1 + 1); // 2
console.log(1 + Number("1")); // 2
++++++++++++++++++++++++++++++++++++++++
One extremely important consideration with respect to JavaScript's
type coercion is the issue of equality.
You might recall that there are two ways to
check if two things are equal in JavaScript: == and ===.
The important thing to realize is that using == implicitly coerces
data types! This means that 1 == "1" will return true.
In reality, these two things are not equal: one is a
string and the other is a number.
To get the proper result, you must use ===.
This is why it's considered a best practice to always use === when checking
equality unless you have a specific reason not to.
Doing so will ensure that you will never end up with two things
that are not really equal being treated as equal because
JavaScript coerced them to the same data type.
Gorgeous Goldfinch