ES6 Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

A block of code, examples being Functions, Objects and Array

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

What does block scope mean?

A

Means the code inside is not accessible from outside the block. (What happens in the code block stays in the code block)

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

What is the scope of a variable declared with const or let?

A

Block Scope

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

What is the difference between let and const?

A

let values can be reassigned,
while a const values are read only

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

Why is it possible to .push() a new value into a const variable that points into an Array?

A

You are able to manipulate an array declared with const but you are unable to reassign it

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

How should you decide on which type of declaration to use?

A

Depending if you want to read only or reassign the variable, if you don’t know ALWAYS use const first

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

What is the syntax for writing a template literal?

A

Backsticks ( )
Newline (\n)
Newline continuation (\n)
Substitution ( ${expression} )

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

What is “string interpolation”

A

A combination of a string and outputs inside the string

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

What is restructuring, conceptually?

A

The breakdown of an array or object

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

What is the syntax for Object destructuring?

A

const or let [ var, var, var… ] = Object

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

What is the syntax for Array destructuring?

A

const or let {var, var, var… } = Array

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

When creating an Object/Array the equal sign goes before the curly brace
When destructuring the equal sign goes after the curly brace

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

What is the syntax of an arrow function?

A

() => expression

param => expression

(param) => expression

(param1, paramN) => expression

() => {
statements
}

param => {
statements
}

(param1, paramN) => {
statements
}

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

When an arrow function’s body is left without curly braces, what changes its functionallity?

A

becomes an expression rather than a statement

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

How is the value of this determined within an arrow function?

A

Within an arrow function the this is not binded to the function

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

What are the three states of Promise can be in?

A

Pending: initial state, neither fulfilled nor rejected

Fulfilled: meaning that the operation was completed successfully

Rejected: meaning that the operation failed

17
Q

How do you handle the fulfillment of a Promise?

A

With .then()

18
Q

How do you handle the rejection of a Promise?

A

With .catch()

19
Q

What does Array.filter do?

A

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.

20
Q

What should the callback function return?

A

If value is true an array of matching values is returned

21
Q

What is Array.filter useful for?

A

To filter out unwanted/ wanted values

22
Q

What does Array.map do?

A

Creates a new array populated with the results of calling a provided function on every element in the calling array.

23
Q

What should the callback function return?

A

Returns a copy of an array with the given expression

24
Q

What is Array.map useful for?

A

To modify everything in an array without looping through it

25
Q

What does Array.reduce do?

A

Walks through an array and reduces it down to a single value

26
Q

What action should the callback function perform?

A

the action it performs is to examine the element, perform an expression and updates the accumulation

27
Q

What should the callback function return?

A

It should return the accumulated value

28
Q

What is Array.reduce useful for?

A

Useful for a few things

29
Q

What are JavaScript classes?

A

Classes are a template for creating objects. They encapsulate data with code to work on that data.

30
Q

When would you want to use a class?

A

When working with data

31
Q

How do you declare a class?

A

with the class keyword

32
Q

How do you inherit from another class?

A

class className extends extendedName {
super( )
}

33
Q

Why would you want to inherit from another class?

A

You want to be able to reuse the original without having it change it

34
Q

How do you add methods and properties to a class?

A