📌  相关文章
📜  检查数组中是否存在值javascript代码示例

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

代码示例1
const fruits = ['apple', 'banana', 'mango', 'guava'];

function checkAvailability(arr, val) {
  return arr.some(arrVal => val === arrVal);
}

checkAvailability(fruits, 'kela');   // false
checkAvailability(fruits, 'banana'); // true