ES6 Flashcards
What is a code block? What are some examples of a code block?
In JavaScript, codeblocks are denoted by { } containing statements, ie(functions, conditionals, loops)
What does block scope mean?
the variable/declaration only exists within the 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 reassigned, const cannot
Why is it possible to .push() a new value into a const variable that points to an Array?
the const reference cannot be changed, but the value can
How should you decide on which type of declaration to use?
const should be used if possible, use let if variables have to be reassigned values
What is the syntax for writing a template literal?
same as regular strings except contained with backticks ( ` ), escape characters must be used if backticks are present in string ( /` ), no escape characters needed to go onto the next line either, just press enter
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
converting items in arrays/objects to single variables
What is the syntax for Object destructuring?
let { property1: variable1, property2: variable2 } = object;
What is the syntax for Array destructuring?
let [x,y,z] = [1,2,3]
How can you tell the difference between destructuring and creating Object/Array literals?
Objects include the property key and are in curly braces while arrays are in square braces
What is the syntax for defining an arrow function?
without block syntax, no return needs to be specified
(parameters) => returnvalue
with block syntax:
(parameters) => {return returnvalue}
When an arrow function’s body is left without curly braces, what changes in its functionality?
you can only have one statement and you don’t need a return statement (implicit return)
How is the value of this determined within an arrow function?
captures the this value of the enclosing context instead of creating its own this context
What is a CLI?
command-line interface (interacts w applications via text)
What is a GUI?
graphical user interface
Give at least one use case for each of the commands listed in this exercise. man cat ls pwd echo touch mkdir mv rm cp
man - find out more about another command cat - combine txt files ls - list contents in a directory pwd - check what directory you are in echo - create txt document touch - update access timestamps and create files if nonexisting mkdir - create directory mv - rename files rm - remove files cp - copy files/directories
What are the three great virtues of a great programmer?
laziness, impatience, hubris
What are the three states a Promise can be in?
pending, fulfilled, rejected
How do you handle the fulfillment of a Promise?
variablename.then(value => { } );
‘then’ method plus function
How do you handle the rejection of a Promise?
variablename.catch(error => { } );
‘catch’ method plus function
OR defining a second function in the .then method
What is “syntactic sugar”?
syntax designed to make things easier to express/read
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
class className { constructor(parameters) { } function(){ } }
What is “refactoring”?
restructuring existing code to improve design/structure or implement new tech without changing the external behavior
How are ES Modules different from CommonJS modules?
different syntax, commonJS is not part of the actual language - its part of node
What kind of modules can Webpack support?
ECMAScript modules, CommonJS modules, AMD modules, Assets, WebAssembly modules