- Tags: String
- Categories: JavaScript Reference, JavaScript Resources, Reference
Quick Reference
This is a quick reference list of JavaScript string methods and properties with examples of how they are used.
JavaScript – String charAt() Method
The String charAt() method returns the character at a specified position in a string.
JavaScript – String charCodeAt() Method
The String charAt() method returns the Unicode (UTF-16) of the character at a specified position in a string.
JavaScript – String codePointAt() Method
The String codePointAt() method returns the Unicode of the character at a specified position in a string.
JavaScript – String concat() Method
The String concat() method joins two or more strings, returning a new string, without changing the existing strings.
JavaScript – String constructor Property
The String constructor property returns the function that created the String prototype.
JavaScript – String endsWith() Method
The String endsWith() method returns true if a string ends with a specified string, if not, it returns false. The method is case sensitive.
JavaScript – String.fromCharCode() Method
The String.fromCharCode() method converts Unicode values to characters.
JavaScript – String includes() Method
The String includes() method returns “true” if a string contains a specified string, if not, it returns “false”. The method is case sensitive.
JavaScript – String indexOf() Method
The String indexOf() method returns the position of the first occurrence of a value in a string, and returns -1 if the value is not found.
JavaScript – String lastIndexOf() Method
The String lastIndexOf() method returns the position of the last occurrence, searching from the end to the beginning, of a specified value in a string.
JavaScript – String length Property
The String length property returns the length of a string. An empty string will return 0.
JavaScript – String localeCompare() Method
The String localeCompare() method compares two strings in the current locale, and returns their sort order -1, 1, or 0 (before, after, equal).
JavaScript – String match() Method
The String match() method matches a string against a regular expression, returning an array with the matches or null if no match is found.
JavaScript – String prototype Property
The String prototype property allows the addition of new properties and methods to strings.
JavaScript – String repeat() Method
The String repeat() method returns a new string with a number of copies of an existing string, without changing the original string.
JavaScript – String replace() Method
The String replace() method searches a string for a value or a regular expression, and returns a new string with the values replaced.
JavaScript – String search() Method
The String search() method matches a string against a regular expression, returning the position of the first match or -1 if no match is found.
JavaScript – String slice() Method
The String slice() method extracts a part of a string, returning the extracted part as a new string, without changing the original string.
JavaScript – String split() Method
The String split() method splits a string into an array of substrings, and returns a new array, without changing the original string.
JavaScript – String startsWith() Method
The String startsWith() method returns “true” if a string starts with a specified string, if not, it returns “false”.
JavaScript – String substr() Method
The String substr() method extracts characters from a string starting at a specified position, returning the extracted part as a new string.
JavaScript – String substring() Method
The String substring() method extracts characters from a string, between two positions, returning a substring, while not changing the original string.
JavaScript – String toLocaleLowerCase() Method
The String toLocaleLowerCase() method converts a string to lowercase letters, using the current locale, without changing the original string.
JavaScript – String toLocaleUpperCase() Method
The String toLocaleUpperCase() method converts a string to uppercase letters, using the current locale, without changing the original string.
JavaScript – String toLowerCase() Method
The String toLowerCase() method converts a string to lowercase letters, without changing the original string.
JavaScript – String toString() Method
The String toString() method returns a string object as a string, without changing the original string.
JavaScript – String toUpperCase() Method
The String toUpperCase() method converts a string to uppercase letters, without changing the original string.
JavaScript – String trim() Method
The String trim() method removes whitespace from both sides of a string, without changing the original string.
JavaScript – String trimEnd() Method
The String trimEnd() method removes whitespace from the end of a string, without changing the original string.
JavaScript – String trimStart() Method
The String trimStart() method removes whitespace from the beginning of a string, without changing the original string.
JavaScript – String valueOf() Method
The String valueOf() method returns the primitive value of a string, without changing the original string.
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
JavaScript Books
All are affiliate links. Thank you for your support!
JAVASCRIPT NOTES:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.