Replace use of Number.isNaN for IE and Safari compatibility
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Browser_compatibility)