ES6 Flashcards

1
Q

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

A

Code blocks are indicated by curly braces and it helps to declare data as local

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

What does block scope mean?

A

Does not create property on global window object. Declaring a variable inside any code block shown by curly brackets and only lives and acts inside.

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

They are blocked-scope compared to var which is global scope or local 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 cannot be reassigned and variable reference cannot change while let can be. Therefore, const needs to be always assigned a value when declared

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 could update the values but cannot change the reference points

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 reassign variables then use let and if variables don’t need to be changed but just the value you can 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

` string content ` - use back-ticks instead of quotes and to substitute a variable and an expression: ${variableName}

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

What is “string interpolation”?

A

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

unpacking values and assigning variables

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

What is the syntax for Object destrucuring?

A

const {property1: variable1, property2: variable2} = 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/let [variable1, variable2, variable3] = 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

Destructuring - you’re not adding any new values to the object or an array and whether assigned variables to existing object/array literals. Destructuring also have brackets go on the lefthand side while creating is on the righthand side.

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 variable = (x,y) => return statement

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

No curly braces will result in implicit return

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

normal this is determined by calltime, but in arrow function you look at where the function is defined or definition time

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

fulfilled: meaning that the operation was completely successful, rejected: meaning that the operation failed, pending: initial state, neither fulfilled nor rejected

17
Q

How do you handle the fulfillment of a Promise?

A

promise.prototype.then()

18
Q

How do you handle the rejection of a Promise?

A

promise.prototype.catch() or optional second function on then()

19
Q

What is “syntactic sugar”?

A

syntax that simplifies reading and expressing - it makes the language “sweeter” for human use

20
Q

What is the typeof an ES6 class?

A

functions

21
Q

Describe ES6 class syntax.

A

class keyword with ObjectName { } - inside the curly braces we use constructor() which is where you can initialize the properties of an instance

22
Q

What is “refactoring”?

A

Process of restructuring existing computer code without changing the behavior

23
Q

How are ES Modules different from CommonJS modules?

A

ES Modules have different syntax and commonJS is part of node rather than

24
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules, etc