javascript check if string contains substring
var string = "foo",
substring = "oo";
console.log(string.includes(substring));const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //truevar 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)var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1);
Also in JavaScript:
- jquery keep scroll position
- trigger button click jquery
- node send file
- if str contains jquery
- how to use inline javascript in html
- javascript async await returns undefined
- foreach db mongodb
- dont starve together
- javascript list object properties
- face-api without projects
- mixin in js
- firebase contains query realtime
- reactnode prop-types
- how to update array in react state
- js convert truthy
- js script
- duplicate encoder
- jquery on window ready
- angular raw
- json nuget package manager
- each javascript
- shuffle json array javascript
- delete all childs in node
- javascript iterate through a binary tree