contains() js code example
Example 1: javascript string contains
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
Example 2: js string contains
var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1);
Example 3: string contains javascript
const s1 = 'javascript';
const s2 = 'python';
console.log(s1.includes('script'));
console.log(s2.includes('script'));
Example 4: javascript includes method
arr.includes(searchElement[, fromIndex = 0])