ES6 Flashcards

1
Q

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

A

Its code within curly braces that are contained within its own block.

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

What does block scope mean?

A

Usually concerned about its functions and variables accessible only within its function or 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

Its 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

Const is not reassigned whereas let is reassigning. A good language will prevent bugs so const will prevent bugs. Linttimeerror.

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

const makes constant references not constant values so its values are mutable.

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

const is not reassigned let is reassigned. Lint rule force const. if let never reassigns, then 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

backtick with ` ${expression}`

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

What is “string interpolation”?

A

converted into a string and concatenate. primitives have to string. methods.

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

What is destructuring, conceptually?

A

Takes fields out of objects and assigns them into variables.

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

keyword (key variable) = object variable

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

[a, b, …rest] = [10, 20, 30, 40, 50];
const [a, b, …rest] = 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

Left hand side is created and right hand side is evaluation.

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

() => {} code

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

It will simply return the arrow expression

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

Go to the lexical, static, parsetime. State of the code or where function is first defined.

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