Here is a list of each method and its description with examples. For example we take a variable
Example :
var str="Hello Afixi";
charAt()
This method returns the character from the specified index. Characters in a string are indexed from left to right. The index of the first character is 0.
This method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex or -1 if the value is not found.
Extracts a section of a string and returns a new string.
If successful, slice returns the index of the regular expression inside the string. Otherwise, it returns -1.
Example :
document.write(str.slice(1,2));
Output :
e
split(separator,limit)
This method splits a String object into an array of strings by separating the string into substrings.
Example :
document.write(str.split(" "));
Output :
Hello,Afixi
substr(start,length)
A portion of a string is returned. A starting and length of the substring are passed to this function.The number of characters to extract. If omitted, it extracts the rest of the string
Example :
document.write(str.substr(7,9));
Output :
fixi
substring(from, to)
This method extracts the characters in a string between "from" and "to", not including "to" itself. The index where to stop the extraction. If omitted, it extracts the rest of the string