es6 Flashcards

1
Q

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

A

if else, for, do while, while, try catch

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

What does block scope mean?

A

the variable defined within the code block (i.e., within the brackets of an if condition, for loop, etc) is only “accessible” within that code block itself - meaning, the variable and it’s respective value are only within that code block, i.e., whatever is defined/assigned in the block scope are rendered as “new” definitions/assignments

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

What is the difference between let and const?

A

the const blocked-scoped variables cannot be reassigned/redeclared (immutable) as opposed to the let blocked-scoped variables can be reassigned (mutable)

if you try to reassign const, you receive a type error (TypeError)

const variables must have an initialized value otherwise you get a syntax error (SyntaxError)

use let if we intend on modifying the variable

using const in a for loop will only evaluate the declaration once before the loop body starts

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 const blocked-scoped variables cannot be reassigned/redeclared (immutable?) as opposed to the let blocked-scoped variables can be reassigned (mutable?)

if you try to reassign const, you receive a type error (TypeError)

const variables must have an initialized value otherwise you get a syntax error (SyntaxError)

use let if we intend on modifying the value of the variable; we can’t modify the variable itself

using const in a for loop will only evaluate the declaration once before the loop body starts

using let does not attach the variable to the global object as property (like the var keyword does)

let creates a new variable in each iteration in a for loop (like var)

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 const variable, in this case, an array, itself is immutable; on the other hand, the array itself is mutable - meaning, you can add new things to the array

think reassignment

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

What is the syntax for writing a template literal?

A

wrapping your text/string in backticks as opposed to double/single quotes

const name = jane doe

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

wrapping your text/string in backticks as opposed to double/single quotes

dollar sign curly and expression within

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

features of template literals

A
  • A multiline string: a string that can span multiple lines.
  • String formatting: the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation.
  • HTML escaping: the ability to transform a string so that it is safe to include in HTML.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is destructuring, conceptually?

A

damn

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

What is destructuring, conceptually?

A

extracting; taking values out of the structure

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
i.e., 
const array = [1, 2, 3, 4];

const [first, ,third] = array;

console.log(first, third); // 1 3

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

deconstructing statement, i.e., the object/array is “rewritten” per se

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

{} [] is the left of the assignment operator means creating

while on the right of the assignment operator means destructuring

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

What is the syntax for defining an arrow function?

A

() => parameters are optional;

if one parameter, optional parantheses
if more than one parameters, mandatory paranthesis

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

no return keyword;

and thus has to be an expression

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

How is the value of this determined within an arrow function?

A

when the value of the function is defined and it’s parent code block

17
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.

18
Q

How do you handle the fulfillment of a Promise?

A

calling the promises’s then method

19
Q

How do you handle the rejection of a Promise?

A

calling promises’s catch method

20
Q

What is Array.prototype.filter useful for?

A

having a variable with a particular set of data you strictly want

21
Q

What is Array.prototype.map useful for?

A

having a certain datapoint being rendered by a callback function

22
Q

What is Array.prototype.reduce useful for?

A

reduces an array to a value

23
Q

What is “syntactic sugar”?

A

simplifying through officially set language predefinitions

24
Q

What is the typeof an ES6 class?

A

function

25
Q

Describe ES6 class syntax.

A

the keyword ‘class’ followed by the className, a constructor within the class code-block, a list of methods

26
Q

What is “refactoring”?

A

simplifying

27
Q

How are ES Modules different from CommonJS modules?

A

statically analyzed vs dynamically analyzed

28
Q

What kind of modules can Webpack support?

A

es modules, commonjs modules, amd modules