JS ES6 Flashcards

1
Q

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

A

statements to be excecuted within curly braces; function, loop, conditional

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

What does block scope mean?

A

exist within curly braces

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

variables created with const cannot have values reassigned

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

the variable is not being reassigned, the content of the array is being updated

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

depending on if the variable will need to be reassigned

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

use backticks instead of single/double quotes

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

taking object/array apart by either properties or index and reassigning them to new 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 { property names seperated by commas} = objname

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 [variable names seperated by commas] =arrayname

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

destructuring has the assignment operator after the curly braces/square brackets rather than when they are being created the assignment operator is before the curly braces/square brackets

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

parameters enclosed in parentheses followed by arrow and curly braces; function word is ommited

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

return statement is not needed and only one statement can be executed in the function without curly braces

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 value of this is determined at definition

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

18
Q

How do you handle the rejection of a Promise?

A

Promise.catch(callback function)

19
Q

What is Array.prototype.filter useful for?

A

creates a new array with all elements that pass the test implemented by the provided function.

20
Q

What is Array.prototype.map useful for?

A

creates a new array populated with the results of calling a provided function on every element in the calling array

21
Q

What is Array.prototype.reduce useful for?

A

executes a reducer function (that you provide) on each element of the array, resulting in single output value.

22
Q

What is “syntactic sugar”?

A

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

23
Q

What is the typeof an ES6 class?

A

function

24
Q

Describe ES6 class syntax.

A
class Name {
    method( ) {
   }
}
25
Q

What is “refactoring”?

A

process of restructuring existing code without changing its behavior

26
Q

How are ES Modules different from CommonJS modules?

A

ES6 modules are pre-parsed in order to resolve further imports before code is executed. CommonJS modules load dependencies on demand while executing the code

27
Q

What kind of modules can Webpack support?

A

ECMAScript modules, CommonJS modules, Asynchronous Module Definition (AMD) modules

28
Q

What must the return value of myFunction be if the following expression is possible? myFunction()();

A

a function

29
Q
What does this code do?
const wrap = value => () => value;
A

returns a function that returns a value and assigns it to the const wrap

30
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

when it’s defined

31
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

closures