indexof negative start value in javascript string code example
Example 1: js array get index
var fruits = ["Banana", "Orange", "Apple", "Mango"];
return fruits.indexOf("Apple"); // Returns 2
Example 2: js indexof string
const paragraph = 'The quick brown fox';
console.log(paragraph.indexOf('T'));
>> 0
console.log(paragraph.indexOf('h'));
>> 1
console.log(paragraph.indexOf('Th'));
>> 0
console.log(paragraph.indexOf('he'));
>> 1
console.log(paragraph.indexOf('x'));
>> 18