Check if the value exists in Array in Javascript

Posted in :

Example:

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Mango");

check if an item exists in an array:

const nums = [ 1, 3, 5, 7];
console.log(nums.includes(3));
// true

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *