ES6 Flashcards
What is a code block? What are some examples of a code block?
{Code inside curly braces that is meant to be grouped}
What does block scope mean?
{everything within that specific code block}
What is the scope of a variable declared with const or let?
block scoped
What is the difference between let and const?
let can be updated but not redeclared , const cannot be updated or re-declared
Why is it possible to .push() a new value into a const variable that points to an Array?
possible to modify the contents.
How should you decide on which type of declaration to use?
cant reassign const. Let is able to reassign.
What is the syntax for writing a template literal?
- you create a template literal by wrapping your text in backticks
- Multiline string: a string that can span multiple lines.
- String formatting: the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation.
- HTML escaping: the ability to transform a string so that it is safe to include in HTML.
What is “string interpolation”?
String formatting: the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation.
What is destructuring, conceptually?
an alternative way to assign properties of an object to variables
What is the syntax for Object destructuring?
- let{
property1 : variable1,
property2 : variable2
} = object;
What is the syntax for Array destructuring?
let [a,b,c] = function or object;
How can you tell the difference between destructuring and creating Object/Array literals?
= object at the end
What is the syntax for defining an arrow function?
var name = (parameters) => expression
When an arrow function’s body is left without curly braces, what changes in its functionality?
dont need a return statement
How is the value of this determined within an arrow function?
First, in the arrow function, the this, arguments, super, new.target are lexical. It means that the arrow function uses these variables (or constructs) from the enclosing lexical scope.