Array Methods Flashcards

1
Q

some()

A

tests if at least one element in the array passes the test implemented by the provided function.

Arrow Function example.

    arr. some( x => x > 10)
    arr. some(x => val === x
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

concat()

A

returns a new array by merging two or more values/arrays.

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

filter()

A

return array with all elements that passed the test defined by the given function.
Does not change the original array.

filter() calls a provided callbackFn function once for each element in an array and constructs a new array of all the values for which callbackFn returns a value that coerces to true.

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

forEach()

A

executes a provided function once for each array element.

Does not change the original array.
Does not return anything
only using data

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

map()

A

executes a provided function once for each array element.It builds a new Array.

does not change the original array.

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

reduce()

A

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.

(accumulator, currentValue) => accumulator + currentValue;

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

pop()

A

remove last item

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

shift()

A

remove first item

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

push()

A

add item to the end

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

unshift()

A

add item to the front

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

splice()

A

removes array items and replaces new items if provided

first start
second how many remove including start
we can use negative numbers.

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

slice()

A

returns a new array containing the specified items except the last index provided.

slice(beginning, end)
Does not modify existing array
Returns a new array

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

indexOf()

A

The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.

Can be used to check if element is present in the array/

if ( arr.indexOf > -1) {}

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

lastIndexOf()

A

returns the last occurrence of the element your searching

return the index of element.

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

includes()

A

This method checks if an item is present in the array and returns a Boolean.

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

find()

A

The find() method returns the value of the first element in the provided array that satisfies the provided testing function.

The find method executes the callbackFn function once for each index of the array until the callbackFn returns a truthy value. If so, find immediately returns the value of that element. Otherwise, find returns undefined.

17
Q

findIndexOf()

A

the findIndex() method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.

18
Q

sort()

A

The sort() method sorts the elements of an array in place and returns the sorted array. The default sort order is ascending.

19
Q

every()

A

every method tests whether all elements in the array pass the test implemented by the provided function

returns a boolean.

20
Q

some()

A

some method tests whether at least one element in the array pass the test implemented by the provided function.

returns a boolean.

21
Q

Key in objects

A

A key is like a variable name that points to a location in memory that holds a value.

22
Q

JavaScript object literal

A

JavaScript object literal is a comma-separated list of name-value pairs wrapped in curly braces. Object literals encapsulate data, enclosing it in a tidy package.

23
Q

this

A

THIS keyword references the calling object which provides access to the calling object’s properties.

The reserved keyword this refers to a method’s calling object, and it can be used to access properties belonging to that object.

24
Q

getters

A

access properties in objects

25
Q

setters

A

change properties in objects. need at least one paramenter

26
Q

factory function

A

returns objects.

27
Q

Object.key()

A

Returns array key names

28
Q

Object.entries()

A

Returns array of key-value pairs. Lets us loop over objects easily.

29
Q

Object.assign()

A

merge objects together.

30
Q

Object.values()

A

Returns values of objects.

31
Q

Objects Data Type

A

An object is a built-in data type for storing key-value pairs. Data inside objects are unordered, and the values can be of any type.

32
Q

Array Data Type

A

Arrays let us gather data items into an ordered list.

33
Q

for in loops

A

Itereate over keys of an object.

34
Q

callback function

A

a function passed into another f as an argument.