Methods Flashcards

1
Q

Imports a library as an object

A

node require(library)
ie let obj = require(‘readline-sync’)

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

destructive, pushes a new element to the end of an array.

A

Array.push()

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

non-destructive, returns a brand new array that contains all the elements from the original array followed by all of the arguments passed to it:

A

Array.concat()

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

destructive, changes the contents of an array by removing or replacing existing elements and/or adding new elementsin place

A

Array.splice(start, deleteCount)

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

non-destructive, creates a new array populated with the results of calling a provided function on every element in the calling array.

A

Array.map()

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

non-destructive, returns a new array that includes all elements from the calling array for which the callback returns a truthy value.

A

Array.filter()

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

non-destructive, reduces the contents of an array to a single value.

A

Array.reduce()

reducetakes two arguments: a callback function and a value that initializes something called theaccumulator.

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

non-destructive

determines whether an array includes a given element

A

Array.includes()

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

non-destructive, searches an array for an element with a given value and returns the index of the found element. If the element is not found,returns-1.

A

Array.indexOf()

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

destructive, rearranges the elements of an array in sequence. It returns a sorted array.

A

Array.sort()

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

non-destructive, extracts and returns a copied portion of the array. It takes two optional arguments. The first is the index at which extraction begins, while the second is where extraction ends (non inclusive of the last index)

A

Array.slice()

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

destructive, reverses the order of an array.

A

Array.reverse()

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

This static method returns an object’s keys as an array. You can iterate over that array using any technique that works for arrays.

A

Object.keys()

returns the object’s own keys: it does not include any keys from the prototype objects.

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

This static method extracts the values from every own property in an object to an array:

A

Object.values()

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

This static method returns an array of nested arrays. Each nested array has two elements: one of the object’s keys and its corresponding value:

A

Object.entries()

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

merges two or more objects to a single object by mutating the first object. Returns the new object.

A

Object.assign(objA, objB)
can be used with an empty object in first place if you want to simply make a copy and not modify the first object.

16
Q

This method checks if some elements exists in an array, and returnstrueorfalse. This is somewhat similar to the concept of theincludes()method, except the argument is a function and not a string.

A

.some()

17
Q

method loops through the array, checks every item, and returnstrueorfalse. Same concept assome(). Except every item must satisfy the conditional statement, otherwise, it will returnfalse.

A

.every()

18
Q

This method is responsible for changing all elements on the array to a static value, starting from the first index (set as 0) to the last index. During this process, updates will finish and return a reference array to the original.

A

.fill()