ES6 Flashcards

1
Q

es6-const-let

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

A

Where you write your code.

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

es6-const-let

What does block scope mean?

A

curly brances, if else, for, do while, while, try catch..

new variable in curly brace
not initialized to any value, not attached to the global object.
redeclaring a vasriable using the let keyword will cause an error.
A temporal dead zone of a variable declared using the let keyword starts from the block until the initialization is evaluated.

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

const block scope, can’t be reassigned. immutable
let: block scope, can be reassigned whenever mutable

var only cares about function, var is function 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

const block scope, can’t be reassigned. immutable

let: block scope, can be reassigned whenever mutable

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 it’s a read-only reference. Because you are not assigning. We are just changing the memory address.

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 I want the variable to never be assigned, use const, in any case, if the variable needs to be reassigned, use let.

const is always better to use than let. Use const first.

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(`) character

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. This feature is also called string interpolation.

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

What is destructuring, conceptually?

A

Getting data from arrays or objects
taking object properties and assigning them to separate variables.
a JavaScript expression that allows us to extract data from arrays, objects, and maps and set them into new, distinct 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 { 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 foo = [‘one’, ‘two’];

const [red, yellow, green, blue] = foo;

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 literal?

A

destructuring assigns values to the properties

on the right side, we are creating, on the left side, we 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

(parameters) => {}

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 the curly brace is used return needs to be there.

if we want to put statements, they need to be in a curly brace.

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

Unlike regular functions, arrow functions do not have their own this. The value of this inside an arrow function remains the same throughout the lifecycle of the function and is always bound to the value of this in the closest non-arrow parent 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: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.

Cannot change when they hit eaither of those.

17
Q

How do you handle the fulfillment of a Promise?

A

Can be fulfilled with a value or rejected with a reason(error). When either of these options happens, the associated handlers queued up by a promise’s then method are called.

18
Q

How do you handle the rejection of a Promise?

A

Processing continues to the next link of the chain even when a .then() lacks a callback function that returns a Promise object. Therefore, a chain can safely omit every rejection callback function until the final .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. It makes the language “sweeter” for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

20
Q

What is the typeof an ES6 class?

A

function

21
Q

Describe ES6 class syntax.

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

What is “refactoring”?

A

the 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

ES module: import and export statements

CommonJS: require function

24
Q

What kind of modules can Webpack support?

A

ES6 and CommonJS