string.contains javascript
var string = "foo",
substring = "oo";
console.log(string.includes(substring));'Blue Whale'.includes('blue') // returns false
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)var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
Also in JavaScript:
- deparam javascript
- javascript array.find
- javascript add item to list
- js replace characters in a string
- default props react
- formidable form node js
- javascript loop nested object
- jasmine spy return value when using create Spy Object angular 2
- javascript infinite parameters
- javascript pluck from array of objects
- jquery test div exists
- jquery typeof undefined
- angular for each
- select 2nd td jquery
- rest operator javascript
- beautiful day at the movies hackerrank solution
- timepicker in jquery
- how to get json file in javascript
- aes 256 nodejs
- javascript get multiple elements by id
- does string contain special charactors javascript
- responsive grid using antd
- crypto nodejs
- inheritance in javascript