String Flashcards

1
Q

String.fromCharCode()

A

params: (num1[, …[, numN]])

num1, …, numN
A sequence of numbers that are Unicode values.

Returns a string created by using the specified sequence of Unicode values.

Note: Because fromCharCode() is a static method of String, you always use it as String.fromCharCode(), rather than as a method of a String object you created.

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

String.fromCodePoint()

A

params: (num1[, …[, numN]])

num1, …, numN
A sequence of code points.

Returns a string created by using the specified sequence of code points.

Note: Because fromCodePoint() is a static method of String, you always use it as String.fromCodePoint(), rather than as a method of a String object you created.

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

String.prototype.anchor()

A

params: (name)

name
The name attribute string

Creates an <a> HTML anchor element that is used as a hypertext target.</a>

Example
document.body.innerHTML = myString.anchor(‘contents_anchor’);</a>

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

String.prototype.charAt()

A

params: (index)

index
The index of the character, 0 to .length-1

Returns character at that index

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

String.prototype.charCodeAt()

A

params: (index)

index
The index of the character, 0 to .length-1

Returns numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000).

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

String.prototype.codePointAt()

A

params: (pos)

pos
Position of an element in the String to return the code point value from.

Returns the UTF-16 encoded code point value.

Example
‘\uD800\uDC00’.codePointAt(0); // 65536

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

String.prototype.concat()

A

params: (string2, string3[, …, stringN])

string2…stringN
Strings to concatenate to this string.

Combines the text of the strings and returns a new string.

Note: + performs better

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

String.prototype.endsWith()

A

params: (searchString[, position])

searchString
The characters to be searched for at the end of this string.
position
Optional. Search within this string as if this string were only this long; defaults to this string’s actual length, clamped within the range established by this string’s length.

Determines whether a string ends with the characters of another string

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

String.prototype.includes()

A

params: (searchString[, position])

searchString
The characters to be searched for within this string.
position
Optional. The position in this string at which to begin searching for searchString; defaults to 0.

Determines whether one string may be found within another string

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

String.prototype.indexOf()

A

params: (searchValue[, fromIndex])

searchValue
String to search for.
fromIndex Optional
The location within the calling string to start the search from.

Returns the index within the calling String object of the first occurrence of searchValue, starting the search at fromIndex. Returns -1 if the value is not found.

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

String.prototype.lastIndexOf()

A

params: (searchValue[, fromIndex])

searchValue
Value to search for
fromIndex
Where to start searching. If negative, it is treated as 0. If fromIndex > str.length, fromIndex is treated as str.length.

Returns last index, or -1 if not found

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

String.prototype.link()

A

params: (url)

url
An escaped URL string

Creates a link

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

String.prototype.localeCompare()

A

params: (compareString[, locales[, options]])

Returns -1 if given string comes before reference string, 0 if they are the same place, and 1 if it comes after.

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

String.prototype.match()

A

params: (regexp)

regexp
A regular expression object or something that can be coerced to regex

Returns an array of matches

Note: If the regular expression does not include the g flag, returns the same result as RegExp.exec(). Also does not return capture groups.

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

String.prototype.normalize()

A

params: ([form])

form
One of “NFC”, “NFD”, “NFKC”, or “NFKD”

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

String.prototype.repeat()

A

params: (count)

Returns the given string repeated $count times

17
Q

String.prototype.replace()

A

params: (regexp|substr, newSubStr|function[, flags])

regexp (pattern)
A RegExp object. The match is replaced by the return value of parameter #2.
substr (pattern)
newSubStr (replacement)
The String that replaces the substring received from parameters. A number of special replacement patterns are supported
function (replacement)
A function to be invoked to create the new substring (to put in place of the substring received from parameter).

Returns a string with all matches of the pattern replaced.

18
Q

String.prototype.search()

A

params: (regexp)

regexp
A RegExp object.

Searches for match between string and RegExp. If found, returns index of first match. If not, returns -1

Note: faster than match for simple check

19
Q

String.prototype.slice()

A

params: (beginSlice[, endSlice])

beginSlice
index to start at. if negative, moves rtl from end
endSlice
index where to end extraction

Extracts and returns a string

20
Q

String.prototype.split()

A

params: ([separator[, limit]])

separator
characters to separate on.
limit
number of splits to be found. still splits every match, but truncates the array

splits a string into an array of strings

21
Q

String.prototype.startsWith()

A

params: (searchString[, position])

searchString
string to be searched for
position
the position to start from

Returns true if string starts with searchString, false otherwise

22
Q

String.prototype.substr()

A

params: (start[, length])

start
index to start at. if negative, rtl from end of string
length
number of characters to extract

Returns string starting at index going for length.

23
Q

String.prototype.substring

A

params: (indexStart[, indexEnd])

indexStart
index to start at
indexEnd
index to end at

Returns the substring between the two indexes, exclusive of indexEnd

24
Q

String.prototype.toLocaleLowerCase()

String.prototype.toLocaleUpperCase()

A

returns the value to lower or uppercase in the host environment’s locale

25
Q

String.prototype.toLowerCase()

String.prototype.toUpperCase()

A

returns upper/lower case

26
Q

String.prototype.toString()

A

overrides the Object.prototype.toString(). Same as valueOf()

27
Q

String.prototype.trim()

A

Return a string with whitespace removed at either end

28
Q

String.prototype@@iterator

A

Returns a new iterator over the code points

Use with for..of

Example 1
for (var val of str)

Example 2
var strIter = stringSymbol.iterator;
console.log(strIter.next().value); // “A”

29
Q

String.rawHi${name}

A

Unprocessed template string, but with substitutions made

Example
String.rawHi${name}