es6 Flashcards
What is a code block? What are some examples of a code block?
In JavaScript, blocks are denoted by curly braces {} , for example the if else, for, do while, while, try catch and so on:
What does block scope mean?
Variable definition is only valid within the scope of the code block it was declared in
What is the scope of a variable declared with const or let?
block scope
What is the difference between let and const?
you can reassign the value for let, not const. Const is also a read only reference?
Why is it possible to .push() a new value into a const variable that points to an Array?
because you are not reassigning the value of the array object?
You are adding to the array not reassigning the variable
What is the syntax for defining an arrow function?
(parameters) => code block
() not needed with one parameter
() are needed with no parameter
{} needed for more than one line of code
When an arrow function’s body is left without curly braces, what changes in its functionality?
You don’t get a return statement
How is the value of this determined within an arrow function?
when it is defined not when its called, that’s regular functions
if arrow left without curly braces
without curly braces, is implicit return