Tablica JavaScript zawiera
var colors = ["red", "blue", "green"];
var hasRed = colors.includes("red"); //true
var hasYellow = colors.includes("yellow"); //false
Grepper
var colors = ["red", "blue", "green"];
var hasRed = colors.includes("red"); //true
var hasYellow = colors.includes("yellow"); //false
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
[1, 2, 3].includes(2); // true
[1, 2, 3].includes(4); // false
[1, 2, 3].includes(1, 2); // false (second parameter is the index position in this array at which to begin searching)
const array1 = [1, 2, 3];
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
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// output: true
const url = 'https://google.com/auth'
const isAuth = url.includes('auth') //true