1var colors = ["red", "blue", "green"];
2var hasRed = colors.includes("red"); //true
3var hasYellow = colors.includes("yellow"); //false
1
2var fruits = ["Banana", "Orange", "Apple", "Mango"];
3var n = fruits.includes("Mango");
4
1let fruits = ["Banana", "Orange", "Apple", "Mango"];
2let do_contain = fruits.includes("Mango"); // contain: true
1let storyWords = ['extremely', 'literally', 'actually', 'hi', 'bye', 'okay']
2let unnecessaryWords = ['extremely', 'literally', 'actually' ];
3
4let betterWords = storyWords.filter(function(word) {
5 return !unnecessaryWords.includes(word);
6});
7console.log(betterWords) // ['hi' 'bye' 'okay]
1const list = [1, 2, 3, 4, 5, 5, 23, 21, 1231, 2434, 443546456, 17];
2console.log(list.includes(4));
3// --> true