Ext.isNumber与Ext.isNumeric

时间:2023-03-09 06:54:00
Ext.isNumber与Ext.isNumeric

Ext.isNumber:

 Ext.isNumber(1)
true
Ext.isNumber(new Number(1))
false
Ext.isNumber("1")
false Ext.isNumber(Number.MAX_VALUE)
true
Ext.isNumber(Number.MIN_VALUE)
true Ext.isNumber(Number.POSITIVE_INFINITY)
false
Ext.isNumber(Number.NEGATIVE_INFINITY)
false

Ext.isNumeric:

 Ext.isNumeric(1)
true
Ext.isNumeric(new Number(1))
true
Ext.isNumeric("1")
true Ext.isNumeric(Number.MAX_VALUE)
true
Ext.isNumeric(Number.MIN_VALUE)
true Ext.isNumeric(Number.POSITIVE_INFINITY)
false
Ext.isNumeric(Number.NEGATIVE_INFINITY)
false

区别在于:

对于数字对象、数字字符串

Ext.isNumber返回false;而Ext.isNumeric返回true