ES6 & Node Flashcards
What is a code block? What are some examples of a code block?
Code block = code between curly braces
Examples: function definitions, if-block, else-block, loop body…etc
What does block scope mean?
Means the binding of the variable only applies in the current code-block.
What is the scope of a variable declared with const or let?
variables declared using const and let are block scoped
What is the difference between let and const?
const -> variable can’t be assigned to a different value; variable also has to be given a value at the time it is declared
let -> variable is mutable (aka can be reassigned) and can be declared without initializing (giving it a value)
Why is it possible to .push() a new value into a const variable that points to an Array?
const means that this variable always points to the same reference/location in memory. However the value at that location in memory can change.
The variable declared with const always points at the array but the value of elements in the array can be changed
How should you decide on which type of declaration to use?
Use const whenever possible; if not possible, use let.
in general the scope of a binding should be as specific as possible
What is the syntax for writing a template literal?
String surrounded by backticks; embedded js variables and expressions inside ${ }
What is “string interpolation”?
substituting values into placeholders in a template string
What is destructuring, conceptually?
Syntax shortcut for assigning properties of an object/elements of an array to individual variables.
What is the syntax for Object destructuring?
const { property1: alias1, property2: alias2 } = objName;
What is the syntax for Array destructuring?
const arr = [1, 2, 3]; const [ var1, var2, var3 ] = arr;
How can you tell the difference between destructuring and creating Object/Array literals?
Creating object/array literal -> object/array literal on right side of assignment operator
Destructuring assignment -> things that looks like an object/array literal on left side of assignment operator
What is the syntax for defining an arrow function?
(parameters) => {
functionBody
}
When an arrow function’s body is left without curly braces, what changes in its functionality?
Implicit return
How is the value of this determined within an arrow function?
Determined by the enclosing lexical scope.
What is a CLI?
Command line interface
What is a GUI?
Graphical user interface
What is Node.js?
Javascript that runs outside/independent of browser.
more technically.
What can Node.js be used for?
Pretty much anything since it’s no longer restricted to the browser.
Usually used for building backends of web applications (server-side scripting), command-line tools, automating tasks.
What is a REPL?
Read-Eval(uate)-Print loop; a simple programming environment; it’s a place to test out snippets of the language
When was Node.js created?
2009
What is a computer process?
An application running on your computer
Why should a full stack Web developer know that computer processes exist?
Full stack Web development is based on making multiple processes (backend/server, frontend/client, and database) work together to form one application
What is the process object in a Node.js program?
A global variable in all Node programs ‘that provides information about, and control over, the current Node.js process’.