ES6 Flashcards

1
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
2
Q

difference between const and let?

A
  1. Const can’t be mutated let is mutable.
    1. They can’t be redeclared in the same scope.
    2. Const has to be initialized when declared.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is it possible to .push(); a new value into a const variable that points to an Array?

A

youre not redefining the variable, the value can be mutated.

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

How should you decide on which type of declaration to use?

A

How should you decide on which type of declaration to use?
If the variable is not going to be reassigned, use ‘const’. If it will be reassigned, then use ‘let’

var is dead unless you want a global variable

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

syntax for template literals

A
  1. Similar to a string, but using back-ticks and a JavaScript expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is “string interpolation”?

A

Embedding variables and expressions with their values.

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

What is the syntax for Object / array destructuring?

A

const {propertName: variableName, , ,} = Object;

const [arrayElements, , , , ] = array;

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

whats the difference between destructuring and creating obj/array literals?

A

the properties and values are on the left side of the assignment operator when destructuring.

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

syntax for arrow function?

A

let add = (x,y) => x + y;

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

what happens when an arrow functions body is w/o curly braces?

A

the result is automatically returned.

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

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

A

at definition time.

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

What is a code block?

A

a block of code within curly braces

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

what does block scope mean?

A

an area within the block where variables can be referenced.

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

What is the JavaScript event loop?

A

The Event Loop is a queue of callback functions. Takes the first thing on the callback queue and puts it back on the stack if the stack is empty

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

what is the difference between blocking and non blocking with respect to how code is executed?

A

Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes.
Non-blocking methods execute asynchronously.

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

Fulfilled, rejected, pending

17
Q

How do you handle the fulfillment and rejection of a promise?

A

.then() and .catch()

18
Q

What is Array.prototype.filter useful for?

A

to create a new array with specific elements from the original array based on truthy values.

19
Q

What is Array.prototype.map useful for?

A

to create a new array containing the transformed elements of another array.

20
Q

what is Array.prototype.reduce useful for?

A

combining the elements of an array into a single value.

21
Q

Syntactic sugar

A

Code that is designed to be easier to read or write.

22
Q

typeof es6 class?

A

function

23
Q

Describe es6 class syntax

A

class keyword, name of class, curly braces for the class body and in the body there are defined prototype methods.

24
Q

refactoring?

A

Restructuring existing code to be easier to read and not changing the behavior

25
Q

webpack

A

a package that can take your modules or packages that incorporates a bundled main.js file with all of it.

26
Q

add a devDependency to a package?

A

npm install –save-dev

27
Q

what is an npm script?

A

An NPM script are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application.

28
Q

execute webpack ?

A

npm run build

29
Q

difference between es modules and commonJS modules?

A
  • ES is the standard for JS, CommonJS is for Node.
    • ES modules has specific keywords. Import, Export, Default..
    • With CommonJS you call a function.
30
Q

What kind of modules can webpack support?

A

ES modules, commonJS modules AMD modules