Now we’re getting to It Flashcards

1
Q

JS: (expression) === VAR ? true: false;

A

Ternary operator evaluating for a Boolean response

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

JS: (expression) === VAR ? true :
(expression) ? true : false;

A

Nested ternary: basically if, else if, else
If the first returns false it moves into second line

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

JS: for (const VAR of ARRAY/STR) {
do something;
}

A

Basic for … of loop. Ideal to iterate thru arrays and strings

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

JS: const { key } = object;
console.log(key);
// prints ‘value’

A

A destructured assignment
Instead of
const key = object.key;

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

JS: const {key} = object;

key.nestedProperty;
or
key.nestedMethod();

A

More destructured assignment to access a nested property

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

JS: array.forEach(item => do something));

A

Array iterator .
NB .forEach well return undefined so you need to do something with it

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

JS; const newArray = array.map(item => {
doSomethingWith item;
});

A

The .map method.
Very similar to .forEach but returns an array

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

JS: .findIndex()

A

Use much like .map and .foreach

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

JS: array.some()

A

Interator method that will check if there are ‘some’ given is criteria and return Boolean

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

JS: array.filter()

A

Iterator checking criteria and returns a new array

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

JS: array.reduce((accumulator, current) => {
return accumulator + current;
})

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

JS: let variable = thisVar || ‘that string’;
Do something;

A

Short circuit evaluation (of an single if/else)
Eg.
if ‘thisVar’ exists use it,
else default to ‘that string’

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