使用Strict Equal在Javascript中无法进行比较

Ron*_*Ron 5 javascript

我有以下基本Javascript来反转我使用时工作的数字

while (!no == 0)

但是当我使用时不起作用

while (!no === 0)

我已经尝试在控制台中只parseInt(0)返回,number而我no已经是number这样

为什么===不工作,有人可以帮助并更好地解释我吗?

function findRepeated(number) {
  var a, no, b, temp = 0;

  no = parseInt(number);


  while (!no == 0) {
    a = no % 10;
    no = parseInt(no / 10);
    temp = temp * 10 + a;
  }
  return temp;
}

console.log(findRepeated(123));
Run Code Online (Sandbox Code Playgroud)

axi*_*iac 8

!no == 0是不一样的!(no == 0).是的(!n) == 0.

类似的!no === 0(!no) === 0.
这总是求值为false因为!no是一个布尔值而且0是一个数字.
永远不会有不同类型的值===.

阅读逻辑NOT运算符,比较运算符运算符优先级.