[Vuejs]-Not in [array] vue js

0👍

How about:

let array1 = ['apple','banana'];
let array2 = ['apple','orange'];
let fruit = 'banana';

let isValid1 = !array1.includes(fruit);
let isValid2 = !array2.includes(fruit);

console.log(isValid1);   // false
console.log(isValid2);   // true

Here is a bit more on includes works:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes

Leave a comment