Strings Flashcards

Get a fucking job

1
Q

What are the two ways of accessing a character?

A

Using the brackets with an index ([i]) or using the charAt() method.

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

What are template strings?

A

Also known as template literals. They’re literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.

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

How is concatenation performed?

A

With the instance method concat(), this method concatenates the string arguments to this string and returns a new string.

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

What is .trim()?

A

An instance method that removes whitespace from both ends of this string, and returns a new string, without modifying the original string.

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

What is . substring()?

A

An instance method that returns the part of this string from the start index up to and EXCLUDING the end index, or to the end of the string if no end index is passed.

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

What is .startsWith()?

A

Instance method that determines if this string starts with the given string. Returns a boolean.

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

What is .replaceAll()?

A

Instance method that returns a new string with all matches of a pattern replaced by a replacement. The original string is left unchanged.

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

What is .replace()?

A

Instance method that returns a new string with the first match of a string pattern replaced by a replacement. The original string is left unchanged. If the pattern is a RegEx, all occurences change.

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

What is .at()?

A

An instance method that returns the character at the index specified. Returns undefined if the index doesn’t exists in the string.

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

What’s the difference between .charAt() and .at()?

A

.charAt() is an older method, .at() was introduced in ECMAScript 2022 (ES13). Also, charAt always returns a string, if the index is out of bounds, it returns an empty string, while the .at() method returns undefined.

Also .at() accepts negative integers.

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