JS ES6 Flashcards

1
Q

variables defined with 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

value cant change. except for data types such as an array or object

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

you can change the value kind of like var

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

what does block scope mean?

A

it is a code block with curley braces. let and const are its own scope

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

you can change information inside the array but as long as the array is still the same array then the const variable is still the same

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

What are some things that var can do that const and let cant?

A

var can hoist

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

because we know where values need to exist and where they dont

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

back tick then dollar sign inside then value inside the curley braces

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

What is string interpolation

A

the process of evaluating a string literal containing one or more placeholders

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

When was the destructuring introduced?

A

in 2015 when ES6 was introduced (ES2015)

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

because of human error

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

if the brackets are on the left side then its destructuring

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

Why was it only set timeout the only ones changed to arrow function?

A

it is executed as if it was in the window scope

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

When arrow functions code block is left without curley braces, what would change?

A

it would return the value without the keyword return. Known as implicit return

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

In what situation would you possibly use an arrow function?

A

for oops without having to use this.

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

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

A

as constructor functions, and no arrow function methods