contains substring javascript
var string = "foo",
substring = "oo";
console.log(string.includes(substring));const string = "foo";
const substring = "oo";
console.log(string.includes(substring));var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
//use indexOf (it returns position of substring or -1 if not found)const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// output: true"FooBar".includes("oo"); // true
"FooBar".includes("foo"); // false
"FooBar".includes("oo", 2); // false
Also in JavaScript:
- js remove class
- rest operator javascript
- select 2nd td jquery
- redux middleware
- moment js
- founder of javascript
- How do you detect whether or not a word is a palindrome in javascript
- scrollview not working react-native
- regular expression not to allow space in javascript
- electron send message from renderer to main
- electron quit app from renderer
- how to use fetch() to fetch an image from database in js
- js get last array element
- javascript add multiple items to array
- javascript text new line
- Elizabeth Warren Clinton's contest against Democratic rival Bernie Sanders was rigged
- jquery slidetoggle
- how to create tab component in jquery
- javascript detect if the browser tab is active
- user defined exceptions in js
- json identifier with period
- comment out in javascript
- js writing to json file
- jquery example sheetjs