Javascript has weak typing, that is, it tries to promote types to make the operation work. In this case, if one type is numeric and the other is string, the string is converted to number. If you want to avoid this conversion, use the == operator, which makes the "strong" comparison, where 3 is different from '3'.
In short, Javascript implicitly converts the data. Do a test, try to put in the console the following operations:
3 * '4'
;true == 1
;!!null
– Arthur Siqueira
Javascript has weak typing, that is, it tries to promote types to make the operation work. In this case, if one type is numeric and the other is string, the string is converted to number. If you want to avoid this conversion, use the == operator, which makes the "strong" comparison, where 3 is different from '3'.
– epx