jemand anders
Erfahrenes Mitglied
Hallo,
wie kann man checken, ob ein Array in anderem Array enthalten ist? Mir gelingt es nicht.
Array.prototype.includes() - JavaScript | MDN
Hat jemand eine Idee?
Grüße
wie kann man checken, ob ein Array in anderem Array enthalten ist? Mir gelingt es nicht.
Javascript:
const array1 = [1, 2, 3, [4], ['x']];
console.log(array1.includes(2));
// expected output: true
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// expected output: true
console.log(pets.includes('at'));
// expected output: false
console.log(array1.includes([4]));
console.log(array1.includes(['x']));
Hat jemand eine Idee?
Grüße