📜  数组方法返回布尔值 - Javascript 代码示例

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

代码示例3
let obj = {"num1":1, "num2":2, "num3":3, "num4":4, "num5":5};

var firstEven = null;

// Some returns a boolean value.
Object.values(obj).some((item) => {
    // Loop breaks as soon as the condition has been met.
      // Getting your value, can be used like:
      if    (item == 2) {
        firstEven = item;
    }
    return item % 2 == 0;
}); // Results in true