【发布时间】:2011-12-27 04:48:11
【问题描述】:
我遇到了一个奇怪的不需要的 Number 到 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
一切都是数字类型,但是当我想返回最终结果时,我得到“不是数字”的结果。 任何人都知道为什么?
周末愉快!
【问题讨论】:
-
它可能相关也可能不相关,但您没有告诉我们
appropriateReferencialRentability和investment的定义在哪里? -
一些数字示例会有所帮助...
-
你真的应该在每一行的末尾使用终结符 (
;)。
标签: jquery numbers nan html-rendering