ES6 Flashcards
what is the scope of a variable declared with const or let?
block scope
difference between const and let?
- Const can’t be mutated let is mutable.
- They can’t be redeclared in the same scope.
- Const has to be initialized when declared.
Why is it possible to .push(); a new value into a const variable that points to an Array?
youre not redefining the variable, the value can be mutated.
How should you decide on which type of declaration to use?
How should you decide on which type of declaration to use?
If the variable is not going to be reassigned, use ‘const’. If it will be reassigned, then use ‘let’
var is dead unless you want a global variable
syntax for template literals
- Similar to a string, but using back-ticks and a JavaScript expression
What is “string interpolation”?
Embedding variables and expressions with their values.
What is the syntax for Object / array destructuring?
const {propertName: variableName, , ,} = Object;
const [arrayElements, , , , ] = array;
whats the difference between destructuring and creating obj/array literals?
the properties and values are on the left side of the assignment operator when destructuring.
syntax for arrow function?
let add = (x,y) => x + y;
what happens when an arrow functions body is w/o curly braces?
the result is automatically returned.
how is the value of this determined within an arrow function?
at definition time.
What is a code block?
a block of code within curly braces
what does block scope mean?
an area within the block where variables can be referenced.
What is the JavaScript event loop?
The Event Loop is a queue of callback functions. Takes the first thing on the callback queue and puts it back on the stack if the stack is empty
what is the difference between blocking and non blocking with respect to how code is executed?
Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes.
Non-blocking methods execute asynchronously.