Recherche de chaîne JS
var str = "This is a test sentence";
var hasTest = str.includes("test");
if(hasTest == true){
//do a thing
}
Lazy Lemur
var str = "This is a test sentence";
var hasTest = str.includes("test");
if(hasTest == true){
//do a thing
}
//regular indexof
let a = 'asbdais sbbdias isajdij';
a.indexOf('ias');
// with regex:
let a = 'asbdais sbbdias isajdij';
a.search(/ias/g);
var string = "Hello world!";
var n = string.search("w"); //now n equals 6
let str = "Please locate where 'locate' occurs!";
str.search("locate");
"I love cats".indexOf("cat") //returns 7, the position of "cat"