String Flashcards
String Instance Methods (31 cards)
Return character value by index
string.at(index)
Return character value by index (non negative)
string.charAt(index)
Return the UTF-16 code by index
string.charCodeAt(index)
Return the unicode code point value
string.codePointAt(index)
Concat two strings
const str1 = “Hello”;
const str2 = “World”;
str1.concat(“-“, str2);
// Hello-World
Check end value
string.endsWith(“value”)
Check for value within string
string.includes(word)
Get index of first occurrence
string.indexOf(word)
Check if string contains surrogates
string.isWellFormed()
Get index of last occurance
string,lastIndexOf(index)
Retrieve array of values using regex
string.match(regex)
Lookup all values using regex (returns iterator)
string.matchAll(regex)
Pad end of string with given string
string.padEnd(value, string)
Pad beginning of string with give string
string.padStart(value, string)
Repeat string
string.repeat(count)
Replace occurrence with new string
string.replace(pattern, replacement)
Replace all occurrences with new string
string.replaceAll(pattern, replacement)
Retrieve index of first occurrence using regex
string.search(regex)
Return a shallow copy of a portion of a string by index
string.slice(startIndex, endIndex)
Divide string into ordered array of substrings
string.split(separator)
Determine if string begins with specified characters
string.startsWith(searchString)
Return part of string based on start and end index
string.substring(startIndex, endIndex)
Return string converted to lower case
string.lowerCase()
Return string converted to upper case
string.toUpperCase()