es6 Flashcards

1
Q

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

A

In JavaScript, blocks are denoted by curly braces {} , for example the if else, for, do while, while, try catch and so on:

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

What does block scope mean?

A

Variable definition is only valid within the scope of the code block it was declared in

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

you can reassign the value for let, not const. Const is also a read only reference?

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

because you are not reassigning the value of the array object?
You are adding to the array not reassigning the variable

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

What is the syntax for defining an arrow function?

A

(parameters) => code block

() not needed with one parameter
() are needed with no parameter

{} needed for more than one line of code

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

You don’t get a return statement

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

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

A

when it is defined not when its called, that’s regular functions

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

if arrow left without curly braces

A

without curly braces, is implicit return

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