My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
String Methods in JavaScript

String Methods in JavaScript

Narasimhulu Vasam's photo
Narasimhulu Vasam
·May 8, 2021·

3 min read

CharAt()

The charAt() string method returns the character at the specified index in a string. The index of the first character is 0, the second character is 1, and so on. Tip: The index of the last character in a string is a string. length-1, the second last character is a string.

toLowerCase()

The toLowerCase() is a string method that converts a string to lowercase letters. Note: The toLowerCase() method does not change the original string.

toUpperCase()

The toUpperCase() is a string method that converts a string to uppercase letters. Note: The toUpperCase() method does not change the original string.

trim()

The trim() is a string method that removes whitespace from both sides of a string. Note: The trim() method does not change the original string.

trimStart()

The trimStart() is a string method that removes whitespace from both left sides of a string. Note: The trimstart() method does not change the original string.

trimEnd()

The trimEnd() is a string method that removes whitespace from both right sides of a string. Note: The trimEnd() method does not change the original string.

concat()

The concat() is a string method is used to join two or more strings. This method does not change the existing strings but returns a new string containing the text of the joined strings.

startsWith()

The startsWith() is a string method that determines whether a string begins with the characters of a specified string

endWith()

The endWith() is a string method that determines whether an end begins with the characters of a specified string.

includes()

The includes() is a string method that determines whether a string contains the characters of a specified string. This method returns true if the string contains the characters, and false if not.

indexOf()

The indexOf() is a string method that returns the position of the first occurrence of a specified value in a string. This method returns -1 if the value to search for never occurs.

padEnd()

The padEnd() is a string method in JavaScript is a string add with another string until it reaches the given length. The padding is applied from the right end of the string.

padStart()

The padStart() is a string method in JavaScript is a string add with another string until it reaches the given length. The padding is applied from the left start of the string.

repeat()

The repeat() is a string method that returns a new string with a specified number of copies of the string it was based on the parameter which we providing.

replace()

The string replace() is an inbuilt method in JavaScript that is used to replace a part of the given string with another string

slice()

The slice() is a string method that extracts parts of a string and returns the extracted parts in a new string.

split("")

The split() is a string method that divides a String into an ordered list of substrings, puts these substrings into an array,