search: it takes a substring as an argument and it returns the index of the first match. The search value can be a string or a regular expression pattern.

PHOTO EMBED

Fri Sep 16 2022 09:20:10 GMT+0000 (Coordinated Universal Time)

Saved by @sreejithbs

let string = 'I love JavaScript. If you do not love JavaScript what else can you love.'
console.log(string.search('love'))          // 2
console.log(string.search(/javascript/gi))  // 7
content_copyCOPY

https://github.com/Asabeneh/30-Days-Of-JavaScript/blob/master/02_Day_Data_types/02_day_data_types.md