JS Methods Flashcards

1
Q

array.splice(startIndex, howMany)

A

Removes item(s) from an array and returns them.

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

array.slice(startIndex, endIndex)

A

Returns selected items as new array without modifying the original. params(startIndex, endIndex). Ending index is not inclusive. Works on string as well.

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

array.toString()

A

Turns array into a string, separated by commas

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

array.join(separator)

A

Turns array into string. Accepts a separator, determining how to separate each item in the array.

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

array.pop()

A

Removes and returns the last item in array.

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

array.push(newItem)

A

Adds a new item to the end of an array. Returns the new array length (integer).

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

array.shift()

A

Removes and returns first element in an array.

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

array.unshift(newItem)

A

Adds newItem to the beginning of an array. Returns the new array length (integer).

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

array.concat(secondArr)

A

Returns new array, the combination of the two arrays.

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

array.sort()

A

Sorts array alphabetically (lexicographically).

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

array.reverse()

A

Reverses the order of an array in place (modifies the original array).

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

array.sort(callbackFn)

A

Sorts the array in place as directed by the callback function

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

Math.max(num1, num2, num3, etc.)

A

Return largest number of the arguments provided

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

Math.min(num1, num2, num3, etc.)

A

Return smallest number of the arguments provided

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

Boolean(x > y)

A

Find if an expression is true or false.

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

string.length OR array.length

A

Returns length of string or array.

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

string.indexOf(‘something’)

A

Returns the index position of ‘something’ or else -1.

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

string.substr(x,y)

A

Returns a string beginning at x and length of y.

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

string.replace(x,y)

A

Replace x with y in the string.

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

string.substring(x,y)

A

Returns the string starting at index x up to but not including index y.

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

string.toUpperCase()

A

Changes all letters to upper case.

22
Q

string.toLowerCase()

A

Changes all letters to lower case.

23
Q

string.charAt(x)

A

Returns character at position x.

24
Q

string.charCodeAt(x)

A

Returns the unicode of the character at position x.

25
string.split("x")
Splits string into array breaking at every "x" character. "" breaks the string at every character.
26
Removes item(s) from an array and returns them.
array.splice(startIndex, howMany)
27
Returns selected items as new array without modifying the original. params(startIndex, endIndex). Ending index is not inclusive. Works on string as well.
array.slice(startIndex, endIndex)
28
Turns array into a string, separated by commas
array.toString()
29
Turns array into string. Accepts a separator, determining how to separate each item in the array.
array.join(separator)
30
Removes and returns the last item in array.
array.pop()
31
Adds a new item to the end of an array. Returns the new array length (integer).
array.push(newItem)
32
Removes and returns first element in an array.
array.shift()
33
Adds newItem to the beginning of an array. Returns the new array length (integer).
array.unshift(newItem)
34
Returns new array, the combination of the two arrays.
array.concat(secondArr)
35
Sorts array alphabetically (lexicographically).
array.sort()
36
Reverses the order of an array in place (modifies the original array).
array.reverse()
37
Sorts the array in place as directed by the callback function
array.sort(callbackFn)
38
Return largest number of the arguments provided
Math.max(num1, num2, num3, etc.)
39
Return smallest number of the arguments provided
Math.min(num1, num2, num3, etc.)
40
Find if an expression is true or false.
Boolean(x \> y)
41
Returns length of string or array.
string.length OR array.length
42
Returns the index position of 'something' or else -1.
string.indexOf('something')
43
Returns a string beginning at x and length of y.
string.substr(x,y)
44
Replace x with y in the string.
string.replace(x,y)
45
Returns the string starting at index x up to but not including index y.
string.substring(x,y)
46
Changes all letters to upper case.
string.toUpperCase()
47
Changes all letters to lower case.
string.toLowerCase()
48
Returns character at position x.
string.charAt(x)
49
Returns the unicode of the character at position x.
string.charCodeAt(x)
50
Splits string into array breaking at every "x" character. "" breaks the string at every character.
string.split("x")