JavaScript Study Notes: Strings
The Concept of Strings
Strings are commonly used to store and process text, using single quotes ('') or double quotes (""), either a pair of double quotes or a pair of single quotes.
Properties and Methods of Strings
length: represents the length of the string.
charAt: gets the character at the specified position
charCodeAt: obtains the ASCII code of the string
concat: concatenates strings
indexOf: finds the first occurrence of the string to search for; if not found, returns -1.
lastIndexOf has the same usage as indexOf, except that it searches from the end.
substr: this method extracts a specified number of characters from the string starting at the start index.
replace: replaces the content of the string, replacing only the found value.
split: converts the string into an array
toUpperCase() // convert to uppercase
toLowerCase() // convert to lowercase
Math usage:
Escape characters:
- \n: newline
- \t: tab
- \': single quote
- ": double quote
- \: backslash
- \r: carriage return
- \f: form feed
Continuing to learn, will add gradually…