Strings Flashcards

1
Q

How do you return the character at a specified index in a string?

A

charAt(index) - Returns the character at the specified index in a string.

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

How do you join two or more strings?

A

concat(string2, string3, …, stringN) - Joins two or more strings and returns a new joined strings.

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

How do you check if a string contains a specified substring?

A

includes(searchString, position) - Checks if the string contains a specified searchString, starting at position if given, returning true or false.

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

How do you find the index of the first occurrence of a specified value in a string?

A

indexOf(searchValue, fromIndex) - Returns the index of the first occurrence of a specified value in a string, starting the search at fromIndex if provided.

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

How do you find the index of the last occurrence of a specified value in a string?

A

lastIndexOf(searchValue, fromIndex) - Returns the index of the last occurrence of a specified value in a string, searching backwards from fromIndex if provided.

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

How do you replace a specified value with another value in a string?

A

replace(regexp|substr, newSubstr|function) - Replaces a specified value (regular expression or substring) with another value in a string.

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

How do you extract a part of a string and return it as a new string?

A

slice(beginIndex, endIndex) - Extracts a part of a string from beginIndex to endIndex (not inclusive) and returns it as a new string.

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

How do you split a string into an array of substrings based on a specified separator?

A

split(separator, limit) - Splits a string into an array of substrings, using a specified separator, and returns the new array.

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

How do you convert a string to lowercase letters?

A

toLowerCase() - Converts a string to lowercase letters.

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

How do you convert a string to uppercase letters?

A

toUpperCase() - Converts a string to uppercase letters.

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

How do you remove whitespace from both ends of a string?

A

trim() - Removes whitespace from both ends of a string.

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

How do you return the Unicode of the character at a specified index in a string?

A

charCodeAt(index) - Returns the Unicode of the character at the specified index in a string.

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

How do you return the character at a specified index, supporting negative indexes to count from the end?

A

at(index) - Returns the character at the specified index. Negative indexes can be used to count from the end of the string.

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

How do you extract characters from a string between two specified indices?

A

substring(indexStart, indexEnd) - Extracts characters from a string between indexStart and indexEnd (not inclusive). Differs from slice in that negative numbers are treated as 0.

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

How do you extract a specified number of characters from a string, starting at a given index?

A

substr(start, length) - Extracts a substring from a string, beginning at start and extending for a given length of characters.

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

How do you return a new string with all matches of a pattern replaced by a replacement?

A

replaceAll(search, replaceWith) - Returns a new string with all matches of a search pattern (string or regular expression) replaced with replaceWith string.

17
Q

How do you construct and return a new string which contains the specified number of copies of the string on which it was called, concatenated together?

A

repeat(count) - Creates a new string consisting of the elements of the calling string repeated count times.

18
Q

Which methods allow you to pad either the start or end of a string with another string?

A

padStart(targetLength, padString) and padEnd(targetLength,padString)

19
Q

Which methods allow you to trim whitespace from either the start or end of a string?

A

trimStart() and trimEnd()

20
Q

How do you search a string for a match against a regular expression, and return the matches?

A

match(regexp) - Searches a string for a match against a regular expression and returns the matches as an Array object.

21
Q

How do you return an iterator of all results matching a string against a regular expression, including capturing groups?

A

matchAll(regexp) - Returns an iterator of all matches of the string against a regular expression, including capturing groups.

22
Q

How do you determine if a string contains a specified substring?

A

includes(searchString, position) - Determines whether the string includes a specified searchString, starting the search at position if given, returning true or false.

23
Q

How do you check if a string starts with a specified string or character?

A

startsWith(searchString, position) - Determines whether a string begins with the characters of a specified searchString, starting the check at position.

24
Q

How do you check if a string ends with a specified string or character?

A

endsWith(searchString, length) - Determines whether a string ends with the characters of a specified searchString, considering the string to be of length characters.

25
Q

How do you find the first occurrence of a specified value in a string?

A

indexOf(searchValue, fromIndex) - Returns the index of the first occurrence of a specified value in a string, starting the search at fromIndex if provided.

26
Q

How do you find the last occurrence of a specified value in a string?

A

lastIndexOf(searchValue, fromIndex) - Returns the index of the last occurrence of a specified value in a string, searching backwards from fromIndex if provided.

27
Q

How do you search a string for a specified value or regular expression and return the index of the match?

A

search(regexp) - Searches a string for a specified value or regular expression and returns the index of the first match.

28
Q

What is the difference between search and indexOf?

A

search cannot take a start position argument. indexOf cannot take regular expressions.