📜  javascript 查找丢失的数字 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:26.345000             🧑  作者: Mango

代码示例1
var a = [5],
  count = 5;
var missing = new Array();

for (var i = 1; i <= count; i++) {
  if (a.indexOf(i) == -1) {
    missing.push(i);
  }
}
console.log(missing); // to check the result.
 Run code snippet