ES6 Flashcards

1
Q

Variables defined with the var keyword are function scoped. const and let are _____ scoped.

A

block-scoped

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

Name some characteristics of a variable declared using const.

A

it is immutable, the value cannot be changed,
however properties can be assigned to it,
must initialize immediately

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

Name some characteristics of a variable declared using let.

A

mutable, value can be changed, and it does not have to be initialized

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

What does block scope mean?

A

its scope is defined by the curly braces it is contained in

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

In the file we can push a new value to an array defined using the const variable. How does that work?

A

it is a reference to the location in memory

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

Name some things that var can do that const and let can’t.

A

they are accessible outside of their blocks, can be hoisted, var can be redeclared, and redefined

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

If var can be used virtually anywhere, why would we switch?

A

minimize the errors that var can cause,

and to have absolute control over the variables being used , (ie no auto global variables)

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

What is the syntax in writing a template literal?

A

use the grave markers ` and then javascript expression ${}

${example}

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

What is string interpolation?

A

allows us to perform javascript expressions within strings

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

When was destructuring introduced?

A

2015 ES6

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

Why could the running commas technique of destructuring an array be a bad idea?

A

If an array is very large, you need a lot of commas; if so, just grab the value the normal way

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

How can you easily tell the difference between destructuring and creating array/object literals.

A

curly braces are on the left side of the equal sign

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

How does an ES6 arrow function differ from an ES5 function?

A

arrow functions dont need to be bound, and they are determined by lexical scope

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

When an arrow function’s code block is left without curly braces, what (if anything) changes in its functionality?

A

without curly braces, the code to the right of arrow will be implicitly returned

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

In what situations would you possibly use an arrow function?

A

callback functions where “this” will have a different value from its normal scope.

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

In what situations would you not want to use an arrow function?

A

when you dont want it to use lexical this