ES 6 Flashcards

1
Q

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

A

Code block is pair of curly braces used to group zero or more statements. Some examples are if else statements, for loops, do while, while loops

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

What does block scope mean?

A

variables only exist within corresponding 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

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

the blocked scoped variables declared using const cannot be reassigned. Let 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

We cannot reassign the variable to another array but const still allows values of the array to be changed.

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

always use const. If const cannot be used, use let.

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 tick, dollar sign, curly braces ${}

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

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into 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

declaration, curly braces, property name.

let { firstName: fname, lastName: lname } = 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

declaration, square brackets, property name.

let [x, y, z] = getScores();

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

instead of values being pulled out of an array, properties (keys) and their values can be pulled out of an object. Object we use curly braces and arrays we use square brackets.

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

let add = (x, y) => x + y;

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 you use the block syntax, you need to specify the return keyword, if not we do not need the return keyword. (no curly braces = 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

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

fulfilled, rejected, or pending

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

In computer science, syntactic sugar is 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 ClassName {
  constructor() { ... }
}
22
Q

How are ES Modules different from CommonJS modules?

A

While CommonJS and ES6 modules share similar syntax, they work in fundamentally different ways: ES6 modules are pre-parsed in order to resolve further imports before code is executed. CommonJS modules load dependencies on demand while executing the code. we use import and export instead of module.exports and require.

23
Q

What kind of modules can Webpack support?

A

Webpack supports the following module types natively: ECMAScript modules. CommonJS modules. ES6, and AMD modules.