ES6 Flashcards

1
Q

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

A

Code blocks are denoted by culry braces { }

The show up in conditionals and functions.

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

What does block scope mean?

A

It means that the var/let and its value is only effective within that code block that it is declared in.

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

they are block-scoped, as they are NOT global and cannot be accessed outside of the block they are contained in

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 CANNOT be reassigned while let can be mutable

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 you can still ADD values to the object, but you cannot reassign the value. So push() is fine, but

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 or not the variable needs to be reassigned or not. if it doesnt, then const would be the choice you should use.

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

let string = ` the text within the string `

instead of using quotes for strings, we are using backticks. This will let the user have multiline strings and be able to use any quotations freely’

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

What is “string interpolation”?

A

The ability to substitute 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

assigns the properties of an object to variables with the same names by default, unless stated otherwise.

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 { object.property1, object.property2…. etc} = object.

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] = array.

This will set the variables of x, y, z to the first 3 indexes of the array.
If the array is < 3, the ‘empty’ variables will be undefined.
If the array is > (the # of listed variables), all argumenst AFTER the last listed variable will be disregarded.

it can use [x, y, … arg] to set all the values after y to another string.

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

object destructuring is mentioning the property the object that contains.
array destructuring only names the new variables that is ‘coming out’

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

(x,y) =>

this states the parameters of the function and what the function is going to do

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

without curly braces, it can only use an expression.

WITH curly braces, you can use a statement and an expression.

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 is “syntactic sugar”?

A

It is a type of syntax that is designed to make things easier to read or to express

17
Q

What is the typeof an ES6 class

A

it is a function

18
Q

Describe ES6 class syntax

A

you start with the ‘class’ keyword followed by ‘${name of function}’ {

class Student {
}
19
Q

What is “refactoring”

A

is the process of restructuring existing computer code- changing the factoring without changing its external behavior.

20
Q

How are ES Modules different from CommonJS modules?

A

they can be statically analyzed(for static checking,optimization, etc)

Their support for cyclic dependencies is better than common JS

21
Q

What kind of modules can Webpack support?

A

ECMAScript6 modules