ES6 Flashcards
What is a code block? What are some examples of a code block?
statements inside curly brackets
statements inside of functions, conditionals or loops
What does the block scope mean?
area within conditionals or loops
something that only exists within the corresponding block
What is the scope of a variable declared with const or let?
block-scope
What is the difference between let and const?
et can be reassigned, const cannot
Why is it possible to .push() a new value into a const variable that points to an Array?
you can change the elements inside of the array, but cannot reassign that array to another array
How should you decide which type of declaration to use?
should use const for anything that will be a constant variable. anything that will need to be reassigned should be let
What is the syntax for writing a template literal?
wrapping your text in backticks accounting for whitespace
What is string interpolation?
the ability to substitute part of the string for the values of variables or expressions
the javascript engine will automatically replace these variables and expressions by their values
What is destructuring conceptually?
an expression that makes it possible to unpack values from arrays or properties from objects, into distinct variables
What is the syntax for Object destructuring?
var, const or let keyword followed by curly braces and the properties you want assigned separated by a colon from the names of the variables you want them assigned to and the object name at the end following the closing curly brace and assignment operator
What is the syntax for Array destructuring?
var, const or let keyword followed by brackets and the variable names you want assigned in the order of the indexes you want assigned to them and the array literal name at the end following the closing bracket and assignment operator
How can you tell the difference between destructuring and creating object/array literals?
object/array name is always at the end when destructuring following the closing curly brace/bracket and the assignment operator
What is the syntax for defining an arrow function?
remove the function keyword.
parameters are listed (if more than one, listen within parentheses) followed by function arrow
multiline statements require body brackets and return
When an arrow function’s body is left without curly braces, what changes in its functionality?
you can use an expression without curly braces but not a statement
How is the value of this determined within an arrow function?
arrow functions establish this based on the scope the arrow function is defined within
in regular functions the this keyword represented the object that called the function, which could be the window, the document, a button, etc
with arrow functions, this always represents the object that defined the arrow function
What is Array.prototype.filter useful for?
allows you to create a new array with all elements that pass a test that you implement
creates a new array while excluding some elements
What is Array.prototype.map useful for?
when you want to transform the each element of an array
What is Array.prototype.reduce useful for?
combining the elements of an array into a single value
What is syntactic sugar?
syntax within a programming language that is designed to make things easier to read or to express
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
class keyword followed by name with first letter capitalized curly brace for class declaration constructor function with parameters
What is refactoring?
process of restructuring existing computer code - changing the factoring - without changing its external behavior.
How are ES Modules different from CommonJS Modules?
more compact syntax
structure can be statically analyzed
support for cyclic dependencies is better than CommonJS
What kind of modules can Webpack Support?
ECMAScript Modules CommonJS modules AMD modules Assets WebAssembly Modules modules written via loaders dependency modules