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
Q

string.split(“x”)

A

Splits string into array breaking at every “x” character. “” breaks the string at every character.

26
Q

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

A

array.splice(startIndex, howMany)

27
Q

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

A

array.slice(startIndex, endIndex)

28
Q

Turns array into a string, separated by commas

A

array.toString()

29
Q

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

A

array.join(separator)

30
Q

Removes and returns the last item in array.

A

array.pop()

31
Q

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

A

array.push(newItem)

32
Q

Removes and returns first element in an array.

A

array.shift()

33
Q

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

A

array.unshift(newItem)

34
Q

Returns new array, the combination of the two arrays.

A

array.concat(secondArr)

35
Q

Sorts array alphabetically (lexicographically).

A

array.sort()

36
Q

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

A

array.reverse()

37
Q

Sorts the array in place as directed by the callback function

A

array.sort(callbackFn)

38
Q

Return largest number of the arguments provided

A

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

39
Q

Return smallest number of the arguments provided

A

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

40
Q

Find if an expression is true or false.

A

Boolean(x > y)

41
Q

Returns length of string or array.

A

string.length OR array.length

42
Q

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

A

string.indexOf(‘something’)

43
Q

Returns a string beginning at x and length of y.

A

string.substr(x,y)

44
Q

Replace x with y in the string.

A

string.replace(x,y)

45
Q

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

A

string.substring(x,y)

46
Q

Changes all letters to upper case.

A

string.toUpperCase()

47
Q

Changes all letters to lower case.

A

string.toLowerCase()

48
Q

Returns character at position x.

A

string.charAt(x)

49
Q

Returns the unicode of the character at position x.

A

string.charCodeAt(x)

50
Q

Splits string into array breaking at every “x” character. “” breaks the string at every character.

A

string.split(“x”)