ES6 Flashcards

1
Q

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

A

statements inside curly brackets

statements inside of functions, conditionals or loops

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

What does the block scope mean?

A

area within conditionals or loops

something that only exists within the corresponding 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-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

et can be reassigned, const cannot

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

you can change the elements inside of the array, but cannot reassign that array to another array

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

How should you decide which type of declaration to use?

A

should use const for anything that will be a constant variable. anything that will need to be reassigned should be 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

wrapping your text in backticks accounting for whitespace

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
the javascript engine will automatically replace these variables and expressions by their values

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

What is destructuring conceptually?

A

an 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

var, const or let keyword followed by curly braces and the properties you want assigned separated by a colon from the names of the variables you want them assigned to and the object name at the end following the closing curly brace and assignment operator

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

var, const or let keyword followed by brackets and the variable names you want assigned in the order of the indexes you want assigned to them and the array literal name at the end following the closing bracket and assignment operator

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/array name is always at the end when destructuring following the closing curly brace/bracket and the assignment operator

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

remove the function keyword.
parameters are listed (if more than one, listen within parentheses) followed by function arrow
multiline statements require body brackets and return

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

you can use an expression without curly braces but not a statement

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

arrow functions establish this based on the scope the arrow function is defined within
in regular functions the this keyword represented the object that called the function, which could be the window, the document, a button, etc
with arrow functions, this always represents the object that defined the arrow function

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

What is Array.prototype.filter useful for?

A

allows you to create a new array with all elements that pass a test that you implement
creates a new array while excluding some elements

17
Q

What is Array.prototype.map useful for?

A

when you want to transform the each element of an array

18
Q

What is Array.prototype.reduce useful for?

A

combining the elements of an array into a single value

19
Q

What is syntactic sugar?

A

syntax within a programming language that is designed to make things easier to read or to express

20
Q

What is the typeof an ES6 class?

A

function

21
Q

Describe ES6 class syntax.

A
class keyword followed by name with first letter capitalized
curly brace for class declaration
constructor function with parameters
22
Q

What is refactoring?

A

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

23
Q

How are ES Modules different from CommonJS Modules?

A

more compact syntax
structure can be statically analyzed
support for cyclic dependencies is better than CommonJS

24
Q

What kind of modules can Webpack Support?

A
ECMAScript Modules
CommonJS modules
AMD modules
Assets
WebAssembly Modules
modules written via loaders
dependency modules