Why does IE give this error: Object doesn't support property or method isNaN
Number.isNaN
This is an experimental technology, part of the Harmony (EcmaScript 6) proposal. Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.
It is still not supported by most of the browsers (including IE11).
You should use a standard isNaN
method instead:
if (isNaN( parseFloat(this.value) )) { ... }
If you are using ES6 with Babel in React. You can do like this:
// pollyfills for older browsers
// core-js v2.x.x:
import 'core-js/es6/number';
// core-js v3.x.x:
import 'core-js/es/number';
Add dependencies in package.json for
"dependencies": {
"core-js": "^2.5.5",
}
I had a similar problem except it was coming from React after it compiled, bundled, and minified. To solve this, I redefined the Number.isNaN
:
if (!Number.isNaN) {
Object.defineProperty(Number, 'isNaN', {
value: function(value) {
return value !== value;
}
});
}