ES6 Flashcards

1
Q

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

A

code blocks are denoted by curly braces { }

ex: if, for, while

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

What does block scope mean?

A

the variable inside the block is a new variable and it shadows the variable declared at the top of the script

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 scoped

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

const - denotes that a variable is a constant and can’t be reassigned

let - can be reassigned

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 to an Array?

A

the actual value to which the const variable reference is not immutable

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

if the variable will be reassigned, the use let

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

wrapping your text in backticks and writing expressions inside ${ }

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

What is “string interpolation”?

A

replacing placeholders with values in a string literal

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

What is destructuring, conceptually?

A

extracting data from arrays or objects into smaller parts

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

let / const keyword {
propertyOfObj: nameOfVariable
} = 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

let / const keyword [varName1, varName2, etc] = 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

creating - the name of the variable comes first

destructuring - curly brace / square bracket comes first

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

What is the syntax for defining an arrow function?

A

(parameter) => {code block}

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 in its functionality?

A

without curly braces, it can only be a single expression, with curly braces, it needs a return keyword

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

an arrow function doesn’t have it’s own this value and captures the this value of the lexical scope (the outer function)

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

What are the three states a Promise can be in?

A

pending, fullfilled, rejected

17
Q

How do you handle the fulfillment of a Promise?

A

Promise.then() returns the message if available

18
Q

How do you handle the rejection of a Promise?

A

Promise.catch() returns an error method

19
Q

What is “syntactic sugar”?

A

syntax in a programming language for easier readability

20
Q

What is the typeof an ES6 class?

A

Function

21
Q

Describe ES6 class syntax.

A
class Name (capitalized) { 
 constructor(1, 2) {
this.1 = 1;
this.2 = 2;
}
}
22
Q

What is “refactoring”?

A

changing the design, structure, or implementation of code while keeping the functionality the same