String Flashcards

String Instance Methods (31 cards)

1
Q

Return character value by index

A

string.at(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Return character value by index (non negative)

A

string.charAt(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Return the UTF-16 code by index

A

string.charCodeAt(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Return the unicode code point value

A

string.codePointAt(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Concat two strings

A

const str1 = “Hello”;
const str2 = “World”;

str1.concat(“-“, str2);
// Hello-World

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Check end value

A

string.endsWith(“value”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Check for value within string

A

string.includes(word)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Get index of first occurrence

A

string.indexOf(word)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Check if string contains surrogates

A

string.isWellFormed()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Get index of last occurance

A

string,lastIndexOf(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Retrieve array of values using regex

A

string.match(regex)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Lookup all values using regex (returns iterator)

A

string.matchAll(regex)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Pad end of string with given string

A

string.padEnd(value, string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Pad beginning of string with give string

A

string.padStart(value, string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Repeat string

A

string.repeat(count)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Replace occurrence with new string

A

string.replace(pattern, replacement)

17
Q

Replace all occurrences with new string

A

string.replaceAll(pattern, replacement)

18
Q

Retrieve index of first occurrence using regex

A

string.search(regex)

19
Q

Return a shallow copy of a portion of a string by index

A

string.slice(startIndex, endIndex)

20
Q

Divide string into ordered array of substrings

A

string.split(separator)

21
Q

Determine if string begins with specified characters

A

string.startsWith(searchString)

22
Q

Return part of string based on start and end index

A

string.substring(startIndex, endIndex)

23
Q

Return string converted to lower case

A

string.lowerCase()

24
Q

Return string converted to upper case

A

string.toUpperCase()

25
Return string value
stringObj.toString()
26
Return string with all lone surrogates replaced with unicode character
string.toWellFormed()
27
Remove whitespace from both ends of a string
string.trim()
28
Remove whitespace from end of a string
string.trimEnd()
29
Remove whitespace from start of a string
string.trimStart()
30
Return a primitive value of a string
string.valueOf()
31