String Methods Flashcards

1
Q

operation performed on strings, including theconcatmethod, results in…

A

a new string

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

Concat can take ________ as arguments. it returns______

A

more than one strings.
all those strings combined into one

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

String.prototype.includes()

A
  • Theincludesmethod takes a string as the argument and returns a boolean signifying whether that string exists within the string thatincludeswas called on.
  • includesalso takes an optional second argument that specifies which index in the string to start looking for the substring.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

String.prototype.trim()

A
  • Thetrimmethod removes whitespace from both ends of the string it’s called on.
  • Thetrimmethod is often useful when getting input from users, which can often contain unnecessary whitespace at either end.
  • trimremoves any number of space characters as well as whitespace characters like\nand\t.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

String.prototype.charAt

A

ThecharAtmethod is nearly identical to using brackets on a string. It takes an index as an argument and returns the character at that index in the given string

The chief difference betweencharAtand[]occurs when using indices for characters that don’t exist:charAtreturns an empty string (‘’), while[]returns undefined:

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

String.prototype.charCodeAt

A
  • The methodcharCodeAtis similar tocharAt, but instead of returning the character at the given index, it returns theUnicode code pointorcharacter codeof the character at that index.
  • A Unicode code point is the number that represents a given character at the machine level.
  • If you don’t provide an index,charCodeAtassumes the index0.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

String.fromCharCode

A
  • TheString.fromCharCodemethod does the opposite ofString.prototype.charCodeAt. It takes a character code (Unicode code point) and returns the character represented by that character code.
  • Note thatfromCharCodeis not a prototype method. It’s instead what we call astatic methodor a function. It can only be called from the string constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

String.prototype.endsWith()

A
  • Returns a boolean represenign if the calling string ends with the passed string. The string argument cant be a regEx.
  • omitting the argument or passingundefinedcausesendsWith()to search for the string"undefined", which is rarely what you want.
  • optional endposition argument if you don’t want the ending position to be str.length
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

String.prototype.startsWith()

A

Same as endsWith but for starting position

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

String.prototype.repeat()

A
  • Therepeat() method ofString constructs and returns a new string which contains the specified number of copies of this string, concatenated together.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly