ES6 Flashcards
What is a code block? What are some examples of a code block?
code that is grouped together and goes together
Functions have a code block of what they will do when called
What does block scope mean?
code only available in the code block it is declared
What is the scope of a variable declared with const or let?
const is a read only reference to a value (as in your not supposed to change the value) and you can not reassign the value
let lets you declare a block scope variable
neither const or let are window objects
What is the difference between let and const?
let you can change the value of what it is set to and const you cant
Why is it possible to .push() a new value into a const variable that points to an Array?
const only prevents you from reassigning the value not from adding or deleting properties
const only holds a pointer value
How should you decide on which type of declaration to use?
if you plan on changing the variable to soot your needs then use let but if its going to be the same use const
What is the syntax for writing a template literal?
Instead of single or double quotes you use backticks
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
simpler way of taking properties out of objects or arrays
What is the syntax for Object destructuring?
instead of variable name its {property name}
What is the syntax for Array destructuring?
instead of variable name its [name you want in the index you want]
How can you tell the difference between destructuring and creating Object/Array literals?
destructuring doesnt change the original array/object
What is the syntax for defining an arrow function?
()=>{}
When an arrow function’s body is left without curly braces, what changes in its functionality?
only the first expression is returned as in implied return
How is the value of this determined within an arrow function?
an arrow function captures the this value of the enclosing context instead of creating its own this context / arrow functions have a lexical scope and take on whatever it is in