You would think, how difficult could it be to compare two values. Well here in JavaScript, it’s a bloody mess. In JavaScript, there are two ways to compare two values. Either we can check two values for the likeness or we can check whether two values are strictly equal in every which way.
The Strict Equality operation is what we are used to. Instead of usual ==
(double equals) operator, we use ===
(triple_ equals_) operator to perform strict equality check. In this operation, A === B
, both A
and B
should be of the same type else the result will be always false
since two values of different data types can’t be equal in any universe. If both have the same data type, then their values are compared.
In the above example, we have compared two values together using strict equality operator (===
). These values could be as simple strings and booleans of primitive data types or abstract/complex data types such as arrays and objects. It produces the following result.
#nodejs #es6 #ecmascript #web-development #javascript