【发布时间】:2020-05-13 03:58:32
【问题描述】:
我一直在试图检查的价值和平等类型的NaN,但我得到的错误每次。这似乎是必须有一个简单的解决方案。这是迄今为止,不工作我已经尝试了四种可能的解决方案。另一件事是,在第一溶液中的下划线无法识别上edabit或codepen:
溶液1 H3>
function checkEquality(a, b) {
if((typeof a === typeof b) ||
(_.isNaN(a) === true) &&
(_.isNaN(b) === true)) {
return true;
}
}
溶液2 H3>
function checkEquality(a, b) {
let divisionByZod = 42 / "General Zod";
let valueIsNaN = (divisionByZod !== divisionByZod);
if((typeof a === typeof b) || (42 / 'General Zod' === true)) {
return true;
}
}
溶液3 H3>
function checkEquality(a, b) {
if(((typeof a === typeof b) || (isNaN(parseInt(NaN))))) {
return true;
}
}
溶液4 H3>
function checkEquality(a, b) {
let c = NaN;
if(((typeof a !== typeof b) || (isNaN(parseInt(c) !== NaN)))) {
return false;
}
}
function checkEquality(a, b) {
if((typeof a === typeof b) ||
(_.isNaN(a) === true) &&
(_.isNaN(b) === true)) {
return true;
}
}
function checkEquality(a, b) {
let divisionByZod = 42 / "General Zod";
let valueIsNaN = (divisionByZod !== divisionByZod);
if((typeof a === typeof b) || (42 / 'General Zod' === true)) {
return true;
}
}
溶液3 H3>
function checkEquality(a, b) {
if(((typeof a === typeof b) || (isNaN(parseInt(NaN))))) {
return true;
}
}
溶液4 H3>
function checkEquality(a, b) {
let c = NaN;
if(((typeof a !== typeof b) || (isNaN(parseInt(c) !== NaN)))) {
return false;
}
}
function checkEquality(a, b) {
if(((typeof a === typeof b) || (isNaN(parseInt(NaN))))) {
return true;
}
}
function checkEquality(a, b) {
let c = NaN;
if(((typeof a !== typeof b) || (isNaN(parseInt(c) !== NaN)))) {
return false;
}
}
【问题讨论】:
-
JavaScript有isNaN内置函数。跨度>
标签: javascript nan equality