js在计算数值时有2个值比较特殊,分别是:NaN 和 Infinity (-Infinity)
Parsing something that isn't a number results in NaN. isNaN helps to detect those cases:
parseInt("hello", 10) // NaN
isNaN(parseInt("hello", 10)) // true
Division through zero results in Infinity:
1 / 0 // Infinity
Both NaN and Infinity are of type "number":
typeof NaN // "number"
typeof Infinity // "number"
Note that NaN compares in a strange way:
NaN == NaN // false (!)
But:
Infinity == Infinity // true
在UEditor里有个问题,上传图片(大图)的时候,进度条的百分比数比如:30%..90%..100%。有可能会变成:Infinity 。
如图:
对应的文件地址:http://camnpr.com/ueditor/dialogs/image/image.js Line 551 修改一行代码,如下:
percent = total ? loaded / total : 0;
spans.eq(0).text(Math.round((percent == Infinity ? 1 : percent) * 100) + '%');// 修改此行
spans.eq(1).css('width', Math.round(percent * 100) + '%');