ES6 Flashcards
What is a code block? What are some examples of a code block?
es6-const-let
What does block scope mean?
es6-const-let
In JavaScript, blocks are denoted by curly braces {} , for example, the if else, for, do while, while, try catch
What is the scope of a variable declared with const or let?
es6-const-let
blocked-scope
What is the difference between let and const?
es6-const-let
lets can be reassigned, const cannot.
Why is it possible to .push() a new value into a const variable that points to an Array?
es6-const-let
You can update and reassign the value, but not what is assigned to the variable
How should you decide on which type of declaration to use?
es6-const-let
everything should be const until it cannot be, then use let. Use let mainly in loops.
What is the syntax for writing a template literal?
es6-template-literals
to create a template literal, wrap your text in backticks (`). for substitution ${}
What is “string interpolation”?
es6-template-literals
The substitutions allow you to embed variables and expressions in a string. The JavaScript engine will automatically replace these variables and expressions with their values.
What is destructuring, conceptually?
es6-destructuring
provides an alternative way to assign properties of an object to variables to store and use
What is the syntax for Object destructuring?
es6-destructuring
const { property1: variable1, property2: variable2 } = object;
What is the syntax for Array destructuring?
es6-destructuring
const [x, y, z] = getScores();
How can you tell the difference between destructuring and creating Object/Array literals?
es6-destructuring
what side the curly bracelets is on. left side is destructuring, right side is creating.
What is the syntax for defining an arrow function?
es6-arrow-functions
const variable name = (…args) => expression
When an arrow function’s body is left without curly braces, what changes in its functionality?
es6-arrow-functions
the arrow function has an implicit return
How is the value of this determined within an arrow function?
es6-arrow-functions
Arrow functions have a lexical this and its value within the arrow function is determined by the surrounding scope.
What is a CLI?
command-line-basics
command line interface
What is a GUI?
command-line-basics
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
command-line-basics
man - command information
cat - print content of text of file
ls - list the files
pwd - check what directory youre on
echo - line of text
touch - Modification time or mtime changes when a file’s contents change.
mkdir - creates a new, empty directory
mv- move and rename files
rm - remove files or directories
cp - copies folder and files
What are the three virtues of a great programmer?
command-line-basics
Laziness, Impatience, and Hubris.
What is Node.js?
node-intro
program that allows js to be run outside of browser
What can Node.js be used for?
node-intro
commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
What is a REPL?
node-intro
read, eval, print loop, allows to run language in background
When was Node.js created?
node-intro
may 2009
What back end languages have you heard of?
node-intro
Java, python, c++
What is a computer process?
node-process
a process is the instance of a computer program that is being executed by one or many threads.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
node-process
a lot
Why should a full stack Web developer know that computer processes exist?
node-process
because they generate application
What is the process object in a Node.js program?
node-process-argv
The process object in Node. js is a global object that can be accessed inside any module without requiring it.
How do you access the process object in a Node.js program?node-process-argv
console.log(process) or const process = require(‘process’);
What is the data type of process.argv in Node.js?
node-process-argv
an array
What is a JavaScript module?
node-module-system
a single .js file. it’s wrapped in functionality that’s easily imported and used.
What values are passed into a Node.js module’s local scope?
node-module-system
exports, require, module, __filename, and __dirname
Give two examples of truly global variables in a Node.js program.
node-module-system
process, exports, require, module, __filename, and __dirname
What is the purpose of module.exports in a Node.js module?
node-require
Module exports are the instructions that tell Node. js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.
How do you import functionality into a Node.js module from another Node.js module?
node-require
To include functions defined in another file in Node.js, we need to import the module. we will use the require function keyword at the top of the file.
What is the JavaScript Event Loop?
the-event-loop
JavaScript has a runtime model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
the-event-loop
Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn’t block execution.
What is a directory?
node-fs-readfile
type of file that contains collections of files
What is a relative file path?
node-fs-readfile
A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.
What is an absolute file path?
node-fs-readfile
An absolute path is defined as the specifying the location of a file or directory from the root directory. like website
What module does Node.js include for manipulating the file system?
node-fs-readfile
fs module
What method is available in the Node.js fs module for writing data to a file?
node-fs-writefile
fs.writeFile()
Are file operations using the fs module synchronous or asynchronous?
node-fs-writefile
What is a client?
http-messages-recap
service requesters
What is a server?
http-messages-recap
workloads between the providers of a resource or service. a software program listen and respond to request
Which HTTP method does a browser issue to a web server when you visit a URL?
http-messages-recap
GET method
What is on the first line of an HTTP request message?
http-messages-recap
A start-line describing the requests to be implemented, or its status of whether successful or a failure. This start-line is always a single line. An HTTP method, The request target, The HTTP version
What is on the first line of an HTTP response message?
http-messages-recap
The start line of an HTTP response, called the status line, contains
The protocol version, usually HTTP/1.1.
A status code, indicating success or failure of the request. Common status codes are 200, 404, or 302
A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.
A typical status line looks like: HTTP/1.1 404 Not Found.
What are HTTP headers?
http-messages-recap
HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value. Whitespace before the value is ignored.
Is a body required for a valid HTTP message?
http-messages-recap
Not all requests have one: requests fetching resources, like GET, HEAD, DELETE, or OPTIONS, usually don’t need one.
What is NPM?
npm-intro
npm is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development
What is a package?
npm-intro
Bits of reusable code. a directory with one or more files in it
How can you create a package.json with npm?
npm-intro
Enter the root folder of your project
Run npm init
Fill out the prompts to create your package.json
What is a dependency and how to you add one to a package?npm-intro
A dependency is another package that your package needs in order to work. Dependencies are specified in your pubspec. You list only immediate dependencies—the software that your package uses directly.
. To add dependencies and devDependencies to a package.json file from the command line, you can install them in the root directory of your package using the –save-prod flag for dependencies (the default behavior of npm install) or the –save-dev flag for devDependencies.
What happens when you add a dependency to a package with npm?
npm-intro
gets stored in the package.json file and in the node module folder
How do you add express to your package dependencies?
express-intro
npm install express
What Express application method starts the server and binds it to a network PORT?
express-intro
listen method ls
How do you mount a middleware with an Express application?
express-hello-world
use method
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
express-hello-world
request and respond method