Why not to use == and always use ===?
Mar 3, 2021
--
Below reasons are responsible for not using ==.
- Execution Time
- Confusion while debugging.
Let’s start with first point
- Execution time:- Where ever it is found by js engine that “==” is used, then javascript will first type cast the second operand value in the data of first operand after which,it compares the both the operand values. While in “===” , it directly compares the both the value and returns the boolean value.
- Confusion while debugging:- Whenever while debugging the code, if let’s say first operand is of type integer and second operand is of string data type, then it may confuse the person and also it is not a good practice to use string to represent the number value.
Thank you please follow me