While writing a sudoku solver, I ran into a issue which took me hours to solve which is based on ['1','2','3'].includes(3)
. is false. Since 3 in includes is a type number but 3 in array is type string. But this is against the intuition that type coercion happens while comparing values in js? Should it be corrected in js?
ex: ['1','2','3'].includes(3) // false
and ['1','2','3'].includes('3') // true
Throw some light on whether this is needed or should be fixed as it will lead to errors in programs if not checked carefully.