ES6 Flashcards

1
Q

What is a code block?

What are some examples of a code block?

A
  • Chunk of code within curly braces

- if statements, loops, functions

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

What does scope mean?

A

It’s not available outside of the code block that it’s currently inside of

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-scope

var is a function-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 updated but not re-declared

- const cannot be updated OR redeclared

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 data in a reference – not the variable itself

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 you know that your value will never change, use const – otherwise 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

` ${ } `

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

What is “string interpolation”?

A

Embedding variables and expressions in a string

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

What is destructuring, conceptually?

A

o Extracting data from objects and arrays

o Taking objects and arrays and converting them into smaller objects, arrays, 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, propeprty2: variable2 } = objectName;

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] = variableName

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

var/let/const followed by {} or []

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

o Parameter => expression
o (parameter1, parameter) => expression

Note: Parentheses for parameters are needed only when there are >1 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

Implicit return (It implies that you want to return)

Note: When you have curly braces, you have to explicitly write ‘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

When the function is being defined (at definition time)

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

18
Q

How do you handle the rejection of a Promise?

A

.catch( )

19
Q

What is “syntactic sugar”?

A

Syntax in a programming language that allows humans to make their code easier to read/write

20
Q

what is the ‘typeof’ n ES6 class?

A

function

21
Q

Describe ES6 class syntax?

A

class Name {

OPTIONAL
constructor(parameter1, …parameters) {
code;
}

OPTIONAL
functionName( ) {
code;
}

};

22
Q

What is refactoring?

A

Process of restructuring existing code but the behavior remains the same