ES-6 Flashcards

1
Q

what is a code block? what are examples of a code block?

A

chunk of code to define statements to be executed together indicated by curly braces

ex. functions, for loops, conditionals (if statements)

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 refers to the area within code block

variables exist only 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

const keyword creates block-scoped variables whose values can’t be reassigned

let - mutable, const- immutable

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

value of the const variable is mutable

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

consider if the variable needs to be reassigned later on within the block scope - if so, let

const - no reassignment
let - reassignment

favor const over let - when you are stuck in a situation where const won’t work, use let

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

what is destructuring, conceptually?

A

allows you 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
8
Q

what is the syntax for Object destructuring? ** { } curly braces for destructuring isn’t considered a code block

A
const/let keyword,
curly braces,
variable names within curly brace,
assignment operator,
variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the syntax for Array destructuring? ** { } curly braces for destructuring isn’t considered a code block

A
const/let keyword,
brackets,
variable names,
assignment operator,
variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

destructuring, check for variable name at the end

or if there is no variable name following const/let

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

what is the syntax for writing a template literal?

A

using back ticks ` `, ${ } for variables

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

what is “string interpolation?”

A

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
13
Q

what is the syntax for defining an arrow function?

A

one param - param => expression (for anonymous)
multiple params - (param1, param2) => expression, requires parantheses
multiple 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

it will return a value without the return keyword (implicit 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

the this value is determined by 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 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

promise.then(onFulfilled[,onRejected])

or

promise.then(value => {//code for fulfillment}

18
Q

how do you handle the rejection of a promise?

A

promise.then

or promise.catch

19
Q

what is syntactic sugar?

A

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

20
Q

what is the type of an ES6 class?

A

function

21
Q

describe ES6 class syntax

A

class declaration, class name

constructor with parameter(s), followed by code block

followed by any functions you want to implement

22
Q

what is refactoring?

A

process of restructuring existing computer code without changing its external behavior/output

23
Q

how are ES modules different from CommonJS modules?

A

ES modules syntax are even more compact than CommonJS

structure can be statically analyzed

their support for cyclic dependencies are better than CommonJS

24
Q

what kind of modules can Webpack support?

A

EMCAScript, CommonJS, AMD (asynchronous module definition)

25
Q

what is Webpack?

A

a tool that lets you bundle your JS applications

26
Q

how do you add a DevDependency to a package?

A

npm install –save-dev

27
Q

what is an NPM script?

A

supports number of built-in scripts and their preset lifecycle events

28
Q

how do you execute Webpack with npm run?

A

add an npm script

npm run build