TIL not to use === to check for NaN
POSTED ON:
TAGS: javascript wat
Avoid using it for troubleshooting.
For example:
function resizeImage(size) {
if (size === NaN) {
console.log('Something is wrong.');
}
}
Doesn't work. The check is always false!
Instead, check it with these:
Number.isNaN(size)
Object.is(size, NaN)
size !== size
Related TILs
Tagged: javascript