JS ES6 Flashcards

1
Q

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

A

A code block is the space between curly braces. Examples include the code block within function definitions. The code block of for loops and 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

Block scope begins at the first curly brace. Any variables defined, or reassigned within block scope are only accessible within that block scope.

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

Their scope is 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 can be reassigned, const can not be. const is a read only reference. let doesn’t have to be initialized to a value when declared… const does.

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 a const variable is read-only… the actual value referenced isn’t immutable

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

the declaration you use should be determined by whether or not a variable is intended to be reassigned or not

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

strings and/or variables written between backticks ( ` ` )

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

What is string interpolation?

A

being able to substitute part of a string with 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

The mass assignment of object properties / array values 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 { objProp1: var1, objProp2: var2 } = mainObj;

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 [ var1, var2, var3 ] = exArray;

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 side on which the curly braces/square brackets are on

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

(p1,p2…) => {

}

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

it becomes an implicit return value

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

this isn’t defined when the arrow function is called, it’s inherited from the parent scope

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, and rejected

17
Q

How do you handle the fulfillment of a Promise?

A

you call the then() method of the Promise and pass whatever you would like done on the fulfillment

18
Q

How do you handle the rejection of a Promise?

A

you call the catch() method of the Promise and pass whatever you would like done on the fulfillment

19
Q

What is Array.prototype.filter useful for ?

A

it’s useful for locating and keeping values based off of some criteria that you provide. it’s a loop and conditional in one function

20
Q

What is Array.prototype.map useful for?

A

it’s useful for doing an expression on each index of an Array

21
Q

What is Array.prototype.reduce useful for?

A

combining the elements of an entire array into a single value

22
Q

What is syntactic sugar?

A

is syntax that is designed to make things easier to read or to express

23
Q

What is the typeof an ES6 class?

A

function

24
Q

Describe ES6 class syntax

A

keyword class and then the name you want your class to be capitalized

25
Q

What is refactoring?

A

the “cleaning up” of code without changing the functionality