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

 ̄綄美尐妖づ 提交于 2019-12-01 14:41:03

问题


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;


回答1:


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



来源:https://stackoverflow.com/questions/31720269/internet-explorer-11-object-doesnt-support-property-or-method-isinteger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!