Skip to content

Instantly share code, notes, and snippets.

@unknownuser88
Created January 6, 2014 13:23
Show Gist options
  • Save unknownuser88/8282832 to your computer and use it in GitHub Desktop.
Save unknownuser88/8282832 to your computer and use it in GitHub Desktop.
indexOf(substr, [start]) Searches and (if found) returns the index number of the searched character or substring within the string. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is 0.
//indexOf(char/substring)
var sentence="Hi, my name is Sam!"
if (sentence.indexOf("Sam")!=-1)
alert("Sam is in there!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment