I have both string and array of strings.
var strFruit = "Apple is good for health";
var arrayFruit = ["Apple is good for health"];
var strResult = strFruit.indexOf("Apple"); //strResult shows 0
var arrayResult = arrayFruit.indexOf("Apple"); // arrayResult shows -1
But if i use arrayFruit.indexOf("Apple is good for health") arrayResult shows 0.
And my Question is why indexOf looks for exact match in Array element but not in string and how both search differ?.
P.S: Main reason to ask this question is i am unable to understand source code for indexOf.I can understand what it does(indexOf) with string and array.But im not sure how it is working with string and Array?(poly fills or source code).