Array JavaScript berisi
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 myList=["a", "b", "c"];
mylist.includes("d")//returns true or false
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// output: true
if(["code","padding",".com"].includes("code")){
// statement if true
}else{
// statement if flase
}
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
let storyWords = ['extremely', 'literally', 'actually', 'hi', 'bye', 'okay']
let unnecessaryWords = ['extremely', 'literally', 'actually' ];
let betterWords = storyWords.filter(function(word) {
return !unnecessaryWords.includes(word);
});
console.log(betterWords) // ['hi' 'bye' 'okay]