js strings popular method
charAt, concat, includes, endsWith, indexOf, lastIndexOf, replace, slice, split, startsWith, substr, toLowercase, toUppercase, trim, trimStart, trimEnd
charAt():this method returns a string.
concat():This method concatenates the string arguments to the calling string and returns a new string.
includes():This method determines if one string may be found within another string, returning true
or false
as appropriate.
endsWith():This method determines if a string ends with the characters of a specified string, returning true
or false
as appropriate.
indexOf():This method returns the index within the calling String
object of the first occurrence of the specified value, starting the search at fromIndex
. Returns -1
if the value is not found.
lastIndexOf():The method returns the index within the calling String
object of the last occurrence of the specified value, searching backwards from fromIndex
. Returns -1
if the value is not found.
replace():This method returns a new string with some or all matches of a pattern
replaced by a replacement
. The pattern
can be a string or a RegExp
, and the replacement
can be a string or a function to be called for each match. If pattern
is a string, only the first occurrence will be replaced.
The original string is left unchanged.
slice():This method extracts a section of a string and returns it as a new string, without modifying the original string.
split():This method divides a String
into an ordered list of substrings, puts these substrings into an array, and returns the array. The division is done by searching for a pattern; where the pattern is provided as the first parameter in the method's call.
startsWith():This method determines whether a string begins with the characters of a specified string, returning true
or false
as appropriate.
substr():This method returns a portion of the string, starting at the specified index and extending for a given number of characters afterwards.
toLowercase():The method returns the calling string value converted to lower case.
toUppercase():The method returns the calling string value converted to uppercase (the value will be converted to a string if it isn't one).
trim():The method removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
trimStart():The method removes whitespace from the beginning of a string. trimLeft()
is an alias of this method.
trimEnd():The method removes whitespace from the end of a string. trimRight()
is an alias of this method.