ES6 Flashcards

1
Q

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

A

a self contained piece of code denoted by curly braces {} if else, 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

variables and functions are only accessible inside the 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-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

The variables declared by the let keyword are mutable
variables created by the const keyword are “immutable” and can’t 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

adding to an array or object you’re not re-assigning or re-declaring the constant, it’s already declared and assigned, you’re just adding to the “list” that the constant points to.
constant is actually storing a reference to the array. When you join something into your array you are not modifying your constant value, but the array it points to.

constants makes references to the variable but not the actual value of the array.

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 you don’t need to reassign the variable, use const. Otherwise 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

Let variableName = String text here with ${variablename}

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

What is “string interpolation”?

A

String formatting: the ability to substitute part of the string for the values of variables or expressions.

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

What is destructuring, conceptually?

A

Setting a value of an element to a new variable
taking specific fields out of an object and assigning it to a variable

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 { property: newVariable, property2: newVariableTwo } = objectName; or can use property as the variable name
for default value, use = defaultvalue

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 [newVariable, newVariable2, newVariable3] = arrayName;
if you don’t want some of the items, use commas nothingin between

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

Destructuring has the elements on the left and object/array on the right of the =
Object array literals have the elements after the = and the object/array literal name before the =

left hand side, being assigned
right hand side being evaluated

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

(arguments) => code block, can also use { 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

If you use an expression in the body of an arrow function, you don’t need to use the curly braces.
However, if you use a statement, you must wrap it inside a pair of curly braces as in the following example:
single expression is returned from the arrow function

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 captures the this value of the enclosing context instead of creating its own this context.
determined by state of the code, lexical scope
Goes upwards to find the nearest object definition or 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 fulfilled rejected

17
Q

How do you handle the fulfillment of a Promise?

A

Promise.then

18
Q

How do you handle the rejection of a Promise?

A

Promise.catch

19
Q

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier to read or to express

20
Q

What is the typeof an ES6 class?

A

object

21
Q

Describe ES6 class syntax.

A

Class keyword followed by the name of the class in upper-case followd by a constructor with its associated properties and any possible associated methods within

Class student {
constructor(parameters, here) {
This.property = property;
this.elapsedSeconds = startTimeInSeconds
}
};

22
Q

What is “refactoring”?

A

process of restructuring existing computer code—changing the factoring—without changing its external behavior

23
Q

How are ES Modules different from CommonJS modules?

A

Uses import and export instead of require() and module.exports

24
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.