Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer 11 : Object doesn't support property or method 'isInteger'

i have this error in internet explorer console ' Object doesn't support property or method 'isInteger' ' how can i resolve it ?

code:

    function verificaNota(nota){
     if (nota.length>0){
         var arr = [];
         if( nota.indexOf(".") != -1 ){
             return ferificareArrayNote(nota.split('.'));
         }else if( nota.indexOf(",") != -1 ){
             ferificareArrayNote(nota.split(','));
         }else if( nota.length<=2 && Number.isInteger(Number(nota)) && Number(nota)<=10 && Number(nota) > 0){
             return true;
         }else {
             return false;
         }
     }
     return true;
    }

And yes, i pass it a number not char;

like image 247
Stefan Avatar asked Jul 30 '15 09:07

Stefan


1 Answers

As stated by @Andreas, Number.isNumber is part of ES6 so not supported by IE11

You can add the following polyfill to you javasript

Number.isInteger = Number.isInteger || function(value) {
    return typeof value === "number" && 
           isFinite(value) && 
           Math.floor(value) === value;
};

source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger

like image 193
Jaromanda X Avatar answered Oct 13 '22 23:10

Jaromanda X