typeof number + typeof number = NaN?
typeof number + typeof number = NaN?
为什么这是JavaScript中的NaN
?
alert(typeof settings.mouse.x + ' --- ' + typeof getScalePercent((bg_w - a_w)/2, settings.bg.perc_position));
// alerts: number --- number
var pos_x = settings.mouse.x - getScalePercent((bg_w - a_w)/2, settings.bg.perc_position);
alert(pos_x);
// alerts: NaN
// this syntax because a jQuery plug-in
var getScalePercent = function (value, perc) {
return value * perc / 100;
}
// settings.mouse.x == 102 basically an integer
// getScalePercent(...) == 10 or 12.0390394028 basically an number
alert(settings.mouse.x + ' (' + typeof settings.mouse.x + ') --- ' + getScalePercent(((bg_w - a_w)/2), settings.bg.perc_position) + '(' + typeof getScalePercent(((bg_w - a_w)/2), settings.bg.perc_position) + ')');
// returns 102 (number) --- 12.000340563 (number)
我哪里错了?
我的猜测是getScalePercent正在返回NaN。由于CCD_ 2正在返回CCD_。检查函数是否完成了您期望的操作。
相关文章:
- 使用模式格式化Number类型输入中的值
- AngularJS {{ val | number:1 }} 不四舍五入到小数点后 1 位
- angular type=[number]指令来阻止粘贴
- 为什么typeof的数组的数组的未定义值返回为“0”;未定义的“;我的条件不认为是真的
- javascript/angularjs 将 String 与 number for loop 连接起来
- a=1和a=new Number()之间的差异
- (typeof variable === “function”) 和 jQuery.isFunction() 有什么区别
- 打印到控制台时为NaN,但typeof为数字jquery
- 为什么Angularjs验证don't与输入[type=“number”]一起工作
- 函数的typeof调用,该函数的名称以字符串形式传递
- typeof new Function()总是“;函数”;
- 为什么使用 Object('123') 创建对象会创建一个 String() 对象,但 typeof 是“对象”
- Javascript Regex - 9-digit number
- input[max={{number}}] 发出非常奇怪的行为
- typeof number + typeof number = NaN?
- 为什么typeof Object、String、Number-Javascript中的一个函数
- 将对象转换为字符串或typeof(number[])给定的类型
- 为什么alert(typeof pageViewCount);它显示"number",而alert(
- Performance if (typeof x == 'number')?
- 为什么typeof回调会变成number