Okay, may be the question was weird. Let me explain a case in hand. I have 5 names in an array eg:
var namesArray=['John','Henry','Smith','James','Carl'];
And I also have a string from some other operation which contains one of these strings with a salutation, say Hello John or Mr.John (note that there is no space in the second one).
var returnedName='Howdy,James!';
What I do know is that the returning string will contain only one of the strings in the mentioned namesArray and no more, and I have no knowledge about the surrounding characters the string may have in returnedName.
What is the fastest way to know which of the strings in the namesArray is a substring of returnedName? I was expecting a function which returns the index of the string in namesArray which is a substring of returnedName. Does such an in-built function exist? If not, what would be the fastest (I have a namesArray of about 100k names, say) way to do that?
 
     
     
     
    