ES6 Flashcards

1
Q

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

A

Code surrounded by curly braces. Ex: if statement, function, for loop

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

What does block scope mean?

A

the block scope restricts the variable that is declared inside a specific 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

const is a var that cannot be reassigned while let is able to 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

you aren’t reassigning a new array, you are just pushing a new value inside

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 want to change the var use let, if you don’t want to change use const

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

back ticks instead of quotes

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

What is “string interpolation”?

A

process in which an expression is inserted or placed in the string.

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

What is destructuring, conceptually?

A

how you get property values or array elements all on one line

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 const or let, curly braces and property and variable names inside curly braces and object it came from

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

keyword const or let, square brackets and property and variable names inside square brackets and object it came from

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

if curly braces or square brackets are on left side of assignment operator then you are destructuring

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

const or let then varName = (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

it does not require a return 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

It is the parents code block

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

you use the then method

17
Q

How do you handle the fulfillment of a Promise?

A

you use the then method

18
Q

How do you handle the rejection of a Promise?

A

you use the catch method

19
Q

What is Webpack?

A

It allows us to take all of script files and combine them into one file

20
Q

How do you add a devDependency to a package?

A

npm install –save-dev “package name”

21
Q

What is an NPM script?

A

a way to automate things using shell command

22
Q

How do you execute Webpack with npm run?

A

npm run build

23
Q

How are ES Modules different from CommonJS modules?

A

it uses import and export not the require method

24
Q

What kind of modules can Webpack support?

A

ecmascript, commonjs, web assembly