ES6 Flashcards

1
Q

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

A

Blocks are notated by curly braces, loops often times

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

What does block scope mean?

A

Means that the variable within the block will not be accessible from outside 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 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

let ‘s value can be reassigned const can not.

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

Because we can change the arrays elements but we cannot reassign the const variable to a new 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 the value needs to be reassigned, use let, otherwise 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

` text ${expression}`

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

What is “string interpolation”?

A

the JavaScript engine will automatically replace these variables ${} and expressions with their values

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

What is destructuring, conceptually?

A

were taking properties or array element values, extracting them to their own 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

let {propKey1: propAlias1, lastname} = 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 [x,y,z] = 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

the curly brackets are on the left side of the assignment operator.

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

(param1, param2) => {
return;
}

param => exp;

() => exp;

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

evaluated as an expression not a statement. result of that expression is returned, 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

lexically, it takes the this from the enclosing function. it is determined at definition for arrow functions. call time for es5 functions.

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: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.

state cannot be changed

17
Q

How do you handle the fulfillment of a Promise?

How do you handle the rejection of a Promise?

A

The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.

18
Q

How do you handle the fulfillment of a Promise?

A

The catch() method returns a Promise and deals with rejected cases only. you pass it a callback function

19
Q

What is “syntactic sugar”?

A

syntactic sugar is 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

a function

21
Q

Describe ES6 class syntax.

A
class Person {
   optional constructor(name) {
        this.name = name;
    }
    getName() {
        return this.name;
    }
}
22
Q

What is “refactoring”?

A

code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior. Refactoring is intended to improve the design, structure, and/or implementation of the software (its non-functional attributes), while preserving its functionality

23
Q

How are ES Modules different from CommonJS modules?

A

ES modules are the standard for JavaScript, while CommonJS is the default in Node. js.
the way you import and export them.

import keyword

export default class name

24
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.