check if string contains substring javascript
const string = "foo";
const substring = "oo";
console.log(string.includes(substring));var string = "foo",
substring = "oo";
console.log(string.includes(substring));const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //truevar str = "Hello world, welcome to the universe.";
var n = str.includes("world");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)var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1);
Also in JavaScript:
- select class with data attribute jquery
- js redirect page
- no frame electron
- javascript convert binary to text
- javascript function from string
- javascript filter array of objects by key
- adding jquery to vuepress
- how to set up a success message show up if form is submitted in react hooks
- escape in javascript
- javascript javascript javascript javascript javascript
- how to update firebase document field angular
- jquery check checkbox
- javascript check if empty
- sorting number with coma datatable
- jquery advace
- turn number into array javascript
- react 17 hot reload not working
- express js sample project
- JavaScript function that generates all combinations of a string.
- javascript array add
- js loop over array of objects extract value
- pyspark json multiline
- hide warnings in expo app
- react keep screen on