JS Other Array Methods Flashcards

1
Q

Concat

A

.concat(condition);
Concatenates two arrays into one array
The Concat method returns (shows) the value of two arrays concatenated into a single array

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

IndexOf

A

.indexOf(condition);

Returns the array (Or string) index position of the value entered

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

Includes

A

.includes(condition);

Determines if an array includes a specific value. Returns a boolean value (AKA True or False)

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

Reverse

A

arrayName.reverse();
Reverses the order of the items in the array.
// NOTE: Returns (shows) the array with the items in reverse order. Also, the Reverse method alters the value of the array it is used on.

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

Slice

A

stringOrArrayName.slice(#, #);
Returns a specified section of a String or an Array. First number determines the starting index. Second number determine the stopping index. Stops before the second number/index (AKA Does NOT include second index).
// NOTE: If a second number is NOT included, then Slice will return (show) the item at the starting index as well as all items that follow.

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

Splice

A

Syntax Example for Splice:
array.splice(Starting Index, Number of Indexes to Remove, Added Item Value(s))

Removes, Replaces, or Adds item(s) to an array.
// First position determines the starting index. Second position determines how many array items to remove starting at the starting index. Third position and on are optional positions that determines the value(s) being set for that/those position(s).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Removing with Splice

A

arrayName.splice(#, #);

NOTE: The array item(s) removed are returned which can be set to a variable

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

Replacing with Splice

A

arrayName.splice(#, #, “replacingItem”, “newItem1”);

NOTE: New value is added at the index specified for the starting index

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

Adding with Splice

A

arrayName.splice(#, #, “newItem”)

NOTE: If there is an item at the specified starting index, then it will be shifted to the right (AKA To the next index)

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