ES6 Flashcards

1
Q

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

A

In JavaScript, codeblocks are denoted by { } containing statements, ie(functions, conditionals, loops)

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

What does block scope mean?

A

the variable/declaration only exists within the 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-scoped

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

let 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

the const reference cannot be changed, but the value can

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

const should be used if possible, use let if variables have to be reassigned values

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

same as regular strings except contained with backticks ( ` ), escape characters must be used if backticks are present in string ( /` ), no escape characters needed to go onto the next line either, just press enter

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

converting items in arrays/objects to single 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 { property1: variable1, property2: variable2 } = 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] = [1,2,3]

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

Objects include the property key and are in curly braces while arrays are in square braces

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

without block syntax, no return needs to be specified
(parameters) => returnvalue
with block syntax:
(parameters) => {return returnvalue}

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 only have one statement and you don’t need a return statement (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

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 a CLI?

A

command-line interface (interacts w applications via text)

17
Q

What is a GUI?

A

graphical user interface

18
Q
Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A
man - find out more about another command
cat - combine txt files
ls - list contents in a directory
pwd - check what directory you are in
echo - create txt document
touch - update access timestamps and create files if nonexisting
mkdir - create directory
mv - rename files
rm - remove files
cp - copy files/directories
19
Q

What are the three great virtues of a great programmer?

A

laziness, impatience, hubris

20
Q

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

21
Q

How do you handle the fulfillment of a Promise?

A

variablename.then(value => { } );

‘then’ method plus function

22
Q

How do you handle the rejection of a Promise?

A

variablename.catch(error => { } );

‘catch’ method plus function

OR defining a second function in the .then method

23
Q

What is “syntactic sugar”?

A

syntax designed to make things easier to express/read

24
Q

What is the typeof an ES6 class?

A

function

25
Q

Describe ES6 class syntax.

A
class className {
     constructor(parameters) {
     }
     function(){
     }
}
26
Q

What is “refactoring”?

A

restructuring existing code to improve design/structure or implement new tech without changing the external behavior

27
Q

How are ES Modules different from CommonJS modules?

A

different syntax, commonJS is not part of the actual language - its part of node

28
Q

What kind of modules can Webpack support?

A

ECMAScript modules, CommonJS modules, AMD modules, Assets, WebAssembly modules