0% found this document useful (0 votes)
2 views13 pages

JavaScript_String_Methods

The document outlines various JavaScript String methods, categorized into character access, comparison, searching, modification, and encoding/decoding. Each method is briefly described, including its purpose and parameters. This serves as a comprehensive reference for developers working with strings in JavaScript.

Uploaded by

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

JavaScript_String_Methods

The document outlines various JavaScript String methods, categorized into character access, comparison, searching, modification, and encoding/decoding. Each method is briefly described, including its purpose and parameters. This serves as a comprehensive reference for developers working with strings in JavaScript.

Uploaded by

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

JavaScript

String
Methods
2nd edition
by
Ankush Bhagat
Character Access

1. charAt(index)
Returns the character at a specified index.

2. charCodeAt(index)
Returns the Unicode value of the character at
a specified index.

3. codePointAt(position)
Returns the code point value of the character
at the specified position.
String Comparison

4. localeCompare(string)
Compares two strings in the current locale.

String Searching

5. includes(searchString[, position])
Checks if the string contains the specified
substring
6. indexOf(searchValue[, fromIndex])
Returns the position of the first occurrence of
a specified value.

7. lastIndexOf(searchValue[, fromIndex])
Returns the position of the last occurrence of
a specified value.

8. startsWith(searchString[, position])
Checks if the string starts with the specified
substring.
9. endsWith(searchString[, length])
Checks if the string ends with the specified
substring.

10. match(regexp)
Searches for a match against a regular
expression and returns the matches.

11. matchAll(regexp)
Returns an iterator for all matched groups in
a string.
12. search(regexp)
Executes a search for a match between a
regular expression and the string.

13. replace(searchFor, replaceWith)


Replaces occurrences of a specified value or
a regular expression.

14. replaceAll(searchFor, replaceWith)


Replaces all occurrences of a specified value
or a regular expression.
15. padStart(targetLength[, padString])
Pads the current string from the start to
reach the target length.

16. padEnd(targetLength[, padString])


Pads the current string from the end to reach
the target length.

String Modification

17. slice(beginIndex[, endIndex])


Extracts a section of the string.
18. substring(indexStart[, indexEnd])
Extracts a part of the string between two
indices.

19. substr(start[, length])


Returns a portion of the string starting at the
specified index and optionally up to the given
length.

20. split([separator[, limit]])


Splits a string into an array of substrings.
21. concat(string1, string2, ...)
Combines two or more strings.

22. toLowerCase()
Converts the string to lowercase.

23. toUpperCase()
Converts the string to uppercase.

24. trim()
Removes whitespace from both ends of the
string.
25. trimStart() or trimLeft()
Removes whitespace from the beginning of
the string.

26. trimEnd() or trimRight()


Removes whitespace from the end of the
string.

27. normalize([form])
Returns the Unicode normalization form of
the string.
String Encoding and
Decoding

28. toString()
Returns the string representation of an
object.

29. valueOf()
Returns the primitive value of a string object.
Raw String Methods

30. String.raw()
A template string tag that returns the raw
string, escaping backslashes.
Follow
for
more

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy