Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views1 page

Strings

Uploaded by

dubeypoorav29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Strings

Uploaded by

dubeypoorav29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

JavaScript Strings

JavaScript provides a rich set of built-in string methods to manipulate and work with text data. These
methods are called on string values and return new string values or other data types, as strings in
JavaScript are immutable.

Here are some important JavaScript string methods:

 slice(start, end):

Extracts a portion of a string and returns it as a new string. The end index is exclusive. Negative
indices count from the end of the string.

 substr(start, length):

Extracts a specified number of characters from a string, starting at a given position.

Methods for Case Conversion:

 toLowerCase(): Converts the entire string to lowercase.

 toUpperCase(): Converts the entire string to uppercase.

 indexOf(substring, start): Returns the index of the first occurrence of a specified substring
within the string. Returns -1 if not found.

 lastIndexOf(substring, start): Returns the index of the last occurrence of a specified


substring.

 includes(substring, start): Checks if a string contains a specified substring and returns a


boolean (true/false).

 startsWith(substring, start): Checks if a string begins with a specified substring.

 endsWith(substring, length): Checks if a string ends with a specified substring.

 concat(string1, string2, ...): Joins two or more strings together.

 split(separator, limit): Divides a string into an ordered list of substrings and returns them as
an array.

 trim(): Removes whitespace from both ends of a string.

 trimStart(): Removes whitespace from the beginning of a string.

 trimEnd(): Removes whitespace from the end of a string.

 charAt(index): Returns the character at a specified index.

 length: A property that returns the length of the string (number of characters).

You might also like