javascript includes code example
Example 1: javascript string contains
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
Example 2: javascript array contains
var colors = ["red", "blue", "green"];
var hasRed = colors.includes("red");
var hasYellow = colors.includes("yellow");
Example 3: javascript string includes
'Blue Whale'.includes('blue')
Example 4: string contains in javascript
const string = "foo";
const substring = "oo";
console.log(string.includes(substring));
Example 5: javascript includes
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
Example 6: javascript includes
includes(searchElement)
includes(searchElement, fromIndex)