substr(): This method also takes 2 parameters. The first parameter is start and second parameter is count or length of characters you want to extract from a given string. The second parameter is optional and if you do not specify second parameter, then all characters from starting position will be extracted as substring. This method does not work in IE8 or earlier versions.
slice(): This method works exactly same as substring() method. But swapping of parameter values will not happen if end parameter is greater than start parameter.
All above 3 methods works fine as long as you know from where to start extraction process. But in case, you are not sure about starting position and want to retrieve it dynamically, then you can use indexOf() method which will return index position of a substring. IndexOf() method takes a string value as a parameter. If the value is found, it will return index position of substring. If the value is not found, it will return -1. Example is given below.