Jquery-奇怪数字到字符串的转换

Jquery-奇怪数字到字符串的转换,jquery,numbers,nan,html-rendering,Jquery,Numbers,Nan,Html Rendering,我遇到了一个奇怪的不需要的数字到NaN转换,不知道在哪里以及为什么。很明显,我在这里遗漏了一些东西,但我不知道是什么 任何建议都欢迎!;) 下面是javascript代码: updatedAbsoluteResult = currentlyDisplayedRentability * investment resultAgainstReferencial = updatedAbsoluteResult - appropriateReferencialRentability * investmen

我遇到了一个奇怪的不需要的
数字
NaN
转换,不知道在哪里以及为什么。很明显,我在这里遗漏了一些东西,但我不知道是什么

任何建议都欢迎!;)

下面是javascript代码:

updatedAbsoluteResult = currentlyDisplayedRentability * investment
resultAgainstReferencial = updatedAbsoluteResult - appropriateReferencialRentability * investment

$('#a0').html('currentlyDisplayedRentability: ' + typeof currentlyDisplayedRentability)
$('#a1').html('investment: ' + typeof investment)
$('#a2').html('updatedAbsoluteResult: ' + typeof updatedAbsoluteResult)
$('#a3').html('appropriateReferencialRentability: ' + typeof appropriateReferencialRentability)
$('#a4').html('resultAgainstReferencial: ' + typeof resultAgainstReferencial )
$('#a5').html('resultAgainstReferencial: ' + resultAgainstReferencial )
以下是HTML输出:

currentlyDisplayedRentability: number
investment: number
updatedAbsoluteResult: number
appropriateReferencialRentability: number
resultAgainstReferencial: number
resultAgainstReferencial: NaN
所有内容都是数字类型,但当我想要返回最终结果时,结果是“不是数字”。 有人知道为什么吗


祝你周末愉快

数值类型可以返回NaN,但仍然是数值类型。检查UpdatedBsolutionResult、适当的ReferenceRentability和investment的值,以查看其中是否有意外值。该等式中可能出现了错误。

数值类型可以返回NaN,但仍然是数值类型。检查UpdatedBsolutionResult、适当的ReferenceRentability和investment的值,以查看其中是否有意外值。很可能这个等式中的某些东西出了问题。

NaN
在javascript中从技术上讲仍然是
number
类型。它通常是由0除引起的。在另一个
NaN
上进行任何数学计算也将返回
NaN

NaN
,在javascript中,从技术上讲,它仍然是
number
类型。它通常是由0除引起的。对另一个
NaN
进行任何数学计算也会返回
NaN

也许具有讽刺意味的是,
NaN
本身就是一个
数字


您可能在某处有一个失败的
parseInt()
调用,或者有许多其他可能。如果没有看到相关的代码,很难猜测。

也许具有讽刺意味的是,
NaN
本身就是一个
数字


您可能在某处有一个失败的
parseInt()
调用,或者有许多其他可能。如果看不到相关的代码,很难猜测。

问题可能是ResultagainsReference是
NaN
。你得到了你想要的结果,因为:

typeof NaN == "number"
向您展示:

resultAgainstReferencial = NaN;
alert(typeof resultAgainstReferencial);   // alerts "number"
你甚至可以在这里看到:


所以,在上游的某个地方,你试图用不是数字的东西来做数学。您必须查看所有数字输入的值,并查看数据哪里出错。

问题可能是ResultaAstreference是
NaN
。你得到了你想要的结果,因为:

typeof NaN == "number"
向您展示:

resultAgainstReferencial = NaN;
alert(typeof resultAgainstReferencial);   // alerts "number"
你甚至可以在这里看到:


所以,在上游的某个地方,你试图用不是数字的东西来做数学。您必须查看所有数字输入的值,并查看数据哪里出错。

这可能相关,也可能不相关,但您没有告诉我们在哪里定义了
适当的可引用性
投资
?一些数字示例可能会有所帮助…您应该真正使用终止符(
)在每行末尾。它可能相关,也可能不相关,但您没有告诉我们在哪里定义了
适当的参考可租性
投资
?一些数字示例可能会有所帮助…您应该在每行末尾使用终止符(
)。