es6 Flashcards

1
Q

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

A

a section of code located within a set of curly braces.

Ex. if else, for, do while, while, etc.

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

What does block scope mean?

A

If a block-scoped variable is declared within a code block, that variable’s value will only be accessible within that code 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

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 is read-only and cannot be reassigned. let values can 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

The array itself is being modified, but the variable name is still pointing to the same 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

Whether a variable’s value will need to be changed or not. If it needs to be changed, then let is needed. If the variable value will not change, then const is needed.

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

Backticks instead of quotes, ${ } for variables/expressions

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

What is “string interpolation”?

A

substituting 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

A syntax that provides an alternative way to assign properties of an object to 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 { firstName: fname, lastName: lname } = person;

let { firstName, lastName } = person;

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] = arrayName;

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 name of the Object/Array literal is on the left side of the assignment operator when creating, and it’s on the right side when 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

( ) => {

}

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

The result of the expression will be returned

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

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

then method

18
Q

How do you handle the rejection of a Promise?

A

catch method

19
Q

What is “syntactic sugar”?

A

A shorter syntax within a programming language that reduces how much code is needed to perform an operation, and improves readability of said code

20
Q

What is the typeof an ES6 class?

A

function

21
Q

Describe ES6 class syntax.

A
class ClassName {
  constructor(property) {
    this.property = property;
  }
  method() {
    code block
  }
22
Q

What is “refactoring”?

A

Simplifying written code to make it shorter and more readable while maintaining the intended function of the original code

23
Q

How are ES Modules different from CommonJS modules?

A

Different syntax (import / export), asynchronous loading, browser use

24
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules