JS ES6 Flashcards
What is a code block? What are some examples of a code block?
statements to be excecuted within curly braces; function, loop, conditional
What does block scope mean?
exist within curly braces
What is the scope of a variable declared with const or let?
block-scope
What is the difference between let and const?
variables created with const cannot have values reassigned
Why is it possible to .push() a new value into a const variable that points to an Array?
the variable is not being reassigned, the content of the array is being updated
How should you decide on which type of declaration to use?
depending on if the variable will need to be reassigned
What is the syntax for writing a template literal?
use backticks instead of single/double quotes
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
taking object/array apart by either properties or index and reassigning them to new variables
What is the syntax for Object destructuring?
let { property names seperated by commas} = objname
What is the syntax for Array destructuring?
let [variable names seperated by commas] =arrayname
How can you tell the difference between destructuring and creating Object/Array literals?
destructuring has the assignment operator after the curly braces/square brackets rather than when they are being created the assignment operator is before the curly braces/square brackets
What is the syntax for defining an arrow function?
parameters enclosed in parentheses followed by arrow and curly braces; function word is ommited
When an arrow function’s body is left without curly braces, what changes in its functionality?
return statement is not needed and only one statement can be executed in the function without curly braces
How is the value of this determined within an arrow function?
the value of this is determined at definition