Arrays Flashcards

Get a job

1
Q

What is … ?

A

Spread syntax. Allows an iterable, such as an array or string, to be expanded in places where zero or more aguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value pairs to the object being created.

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

What is .at()?

A

A method of an Array instance (Array.prototype.at()). Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.

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

What is .every()?

A

An instance method from an Array. Tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.

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

What is .filter()?

A

Instance method. Creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.

For primitive values, filter creates a new independent copy.

For objects or arrays, filter creates a new array, but with references to the same objects as the original array.

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

What is .find()?

A

Instance method that returns the first element in the provided array that satisfies the provided testing function.

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

What is .forEach()?

A

Instance method that executes a provided function once for each array element.

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

What is .includes()?

A

Instance method that determines whether an array includes a certain value among its entries. Returns a Boolean value.

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

What is .join()

A

Instance method that returns a new string by concatenating all of the elements in this array, separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.

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

What is .length

A

Data property of an array instance. Returns a non negative integer that represents the number of elements in that array. The value is an unsigned 32-bit integer that is always numerically greater that the highest index in the array.

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

What is .map()

A

Instance method that creates a new array populated with the results of calling a provided function on every element in the calling array.

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

What is .push()

A

Instance method that adds the specified elements to the end of an array and returns the new length of the array.

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

What is .reduce()?

A

Instance method that executes a user-supplied “reducer” callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.

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

What is .some()?

A

Instance method that tests whether at least one element in the array passes the test implemented byu the provided function. Returns a Boolean value.

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

What is .splice()

A

Instance method that CHANGES the contents of an array by removing or replacing existing elements and/or adding new elements in place.

To create a new array with a segment removed and/or replaced without mutating the original array, use toSpliced(). To access part of an array without modifying it, .slice()

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

What is .slice()?

A

Instance method that returns a shallow copy of a portion of an array into the new array object selected fromt start to end (end NOT included) where start and end represent the index of items in that array. The original array doesn’t get modified.

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

What is a shallow copy?

A

A copy of an object whose properties share the same references (point to the same underlying values) as those of the source object from which the copy was made.

More formally, two objects o1 and o2 are shallow copies if:

  1. They are not the same object (o1 !== o2)
  2. The properties of o1 and o2 have the same names in the same order
  3. The values of their properties are equal
  4. Their prototype chains are equal
16
Q

Characteristics of JavaSript arrays

A
  1. JavaScript arrays are resizable and can contina a mix of different data types (when those characteristics are undesirable, use typed arrays instead).
  2. JavaScript arrays are not associative arrays. Array elements cannot be accessed using arbitrary values as indexes, but must be accessed using nonnegative integers (or their respective string form) as indexes.
  3. JavaScript arrays are zero-indexed.
  4. JavaScript array-copy operations create shallow copies. All standard built -in copy operations with any JavaScript objects create shallow copies rather than deep copies.
17
Q

What are copying methods?

A
  • Copying methods are the built in methods that perform copy operations.
  • Copy operations are performed shallowly (instead of doing deep copies).
  • When copying an array, primitives are copied into the new array, while objects or other arrays get references their copied into the new array instead of the value itself.
18
Q

What are mutating methods?

A
  • Methods that mutate the array that the method is being called on. Depending on the method, the return value differs, sometimes a reference to the same array, sometimes the length of then new array.
19
Q

What is .isArray()?

A

Static method that returns true if the argument is an array.