Common String Properties
constructor - tells us the function that created the String object's prototype
length - returns the total number of characters in a string
Common String Methods
A string is a very changeable variable, which means you need to be careful when using string methods. Many of the string methods will manipulate the initial value of the string, which cannot be recovered. You might have noticed already, but methods are easily distinguished by the fact they have () following them.
charAt() - returns character using its index
indexOf() - returns the index of the first instance of a specified value
lastIndexOf() - returns the index of the last instance of a specified value
match() - finds all matches in the string of a specified value
replace() - finds all matches in the string of a specified value and then replaces them with a new substring
search() - looks for a match in the string with a specified substring and returns the substrings index in the string
slice() - extracts and returns part of the string
split() - splits string into an array of substrings
substr() - extracts characters from a string starting at a specified position and ending at a specified length from the starting position
substring() - extracts characters from a string starting between two specified positions
toLowerCase() - converts all letters in string into lowercase
toUpperCase() - converts all letters in string into uppercase
Your code will execute in this window.
Let's explore some more tutorials or topics!
No comments yet... Be the first!