ES6 Flashcards
What is the syntax for writing a template literal?
it uses backticks instead of quotes
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
unpacking values from objects or arrays and assigning it to variables
What is the syntax for Object destructuring?
variable declaration curly braces property keys equal sign and object being destructured
what is the syntax for array destructuring?
variable declaration square brackets elements and array being destructured
How can you tell the difference between destructuring and creating Object/Array literals?
destructuring has the array/object on the left of the equal sign. creating has it on the right side of the equal sign.
What is syntax for defining an arrow function?
parameter, arrow function keyword, statement/expression
When an arrow function’s body is left without curly braces, what changes in its functionality?
doesn’t need a return statement
How is the value of this determined within an arrow function?
at definition time
What is Node.js
its an asynchronous event-driven JavaScript runtime. aka you run js outside the web browser
What can Node.js be used for?
it can be used to build scalable network applications like web servers or cmd line applications.
What is REPL
it stands for read-eval-print loop that takes a single user input executes them and returns the result to the user.
When was Node.js created?
2009
What back end languages have you heard of?
Node, python, ruby, c, c++, java, c#, php, JavaScript, go, rust
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
around 300+cd processes
Why should a full stack Web developer know that computer processes exist?
because they are making multiple processes work together to form one application.
what is a computer process
the instance of a computer program being executed by one or many threads.
what is the process object in a Node.js program?
an object that provides information about, and control over, the current node.js process.
How do you access the process object in a Node.js program?
its always available to node.js applications without using require().
What is the data type of process.argv in Node.js?
an array of strings
what is a javascript module?
a js file
What values are passed into a Node.js module’s local scope?
__dirname __filename module require exports
Give two examples of truly global variables in a Node.js program.
process, console, global
what is the event.loop
The event loop is a process that keeps running and checks whether the call stack is empty or not. If the call stack is empty, it pushes the first item of the message queue into the call stack for execution.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking makes the further execution of code not run until the first execution is finished while non-blocking doesn’t block execution. it makes it so we can’t do anything in the browser until the code finishes running.
What module does Node.js include for manipulating the file system
the filesystem module
what is an absolute file path?
An absolute file path is the full URL to a file, an absolute path refers to the same location in a file system relative to the root directory
what is a relative file path?
A relative file path points to a file relative to the current directory
what is a directory?
a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories
What method is available in the Node.js fs module for writing data to a file?
writeFile method
Are file operations using the fs module synchronous or asynchronous?
both because there’s file and fileSync
what is a client?
service requesters who request data from a server.
what is a server?
the providers of resources or service , a server is a piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called “clients”
Which HTTP method does a browser issue to a web server when you visit a URL
the get method?
What is on the first line of an HTTP request message?
http method, request, http version
What is on the first line of an HTTP response message?
http protocol version, status code, status text
What are HTTP headers?
An HTTP header consists of its case-insensitive string followed by a colon (:), then by its value. let the client and the server pass additional information with an HTTP request or response. aka meta data about the request or response.
Is a body required for a valid HTTP message?
nope
What is NPM?
npm is the world’s largest software registry that consists of the website, the Command Line Interface (CLI), and the registry
What is a package?
A package is a file or directory that is described by a package.json file. A package must contain a package.json file in order to be published to the npm registry.
How can you create a package.json with npm?
npm init –yes
What is a dependency and how to you add one to a package?
they are packages required by your application during production. with npm install then the package name
What happens when you add a dependency to a package with npm?
it creates a node_modules directory within the root directory.
How do you add express to your package dependencies?
npm install express
What Express application method starts the server and binds it to a network PORT?
listen method
How do you mount a middleware with an Express application?
with the use method
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object and response object
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json charset= utf8
What does the express.json() middleware do and when would you need it?
it parses incoming requests with JSON payloads and is based on body-parser, when your app needs to know how to parse JSON request bodies.
What is the significance of an HTTP request’s method?
to indicate the desired action to be performed for a given resource
What is PostgreSQL and what are some alternative relational databases?
a powerful, open source object-relational database, mySQL, SQL server by microsoft, oracle by oracle corporation
What are some advantages of learning a relational database?
Many problem domains can be modeled well using a relational database, they support good guarantees about data integrity. This means that developers can set up their database to reject “bad” data and not worry about data being “half written”
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
A schema defines how the data in a relational database should be organized and is also a collection of tables. its a plan for your data.
What is a table?
a table is a list of rows having the same set of attributes
What is a row?
its a single, implicitly structured data item in a table
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative programming language that can retrieve create and manipulate data in a relational database.
How do you retrieve specific columns from a database table?
using the select statement followed by list
How do you filter rows based on some specific criteria?
the where clause
What are the benefits of formatting your SQL?
consistent style and readability
How do you limit the number of rows returned in a result set?
with the limit clause
How do you retrieve all columns from a database table?
with the asterisk
How do you control the sort order of a result set?
order by is default ascending so if you want descending add desc to the end .
How do you add a row to a SQL table?
with the insert into statements followed by the category and parentheses that hold the attributes.
what is a tuple?
A list of values that are wrapped in the parentheses
How do you add multiple rows to a SQL table at once?
you specify more than one tuple of values separated by commas.
How do you get back the row being inserted into a table without a separate select statement?
with a returning asterisk
how do you update rows in a database table?
With the update statement and name of the table
Why is it important to include a where clause in your update statements?
So it only targets specific rows
How do you delete rows from a database table?
with a delete from statement and the table, a where clause with the category an operator and the attribute
How do you accidentally delete all rows from a table?
delete from “table”
what is a foreign key
the attributes that connect two different tables
How do you join two SQL tables?
with the join clause category using the foreign key
How do you temporarily rename columns or tables in a SQL statement?
using as keyword
What are some examples of aggregate functions?
count sum max min avg
What is the purpose of a group by clause?
to separate rows into groups and perform aggregate functions on those groups of rows
What is Array.prototype.filter useful for?
returning a new array with values that pass a test?
What is Array.prototype.map useful for?
creates a new array populated with the results of calling a provided function on every element in the calling array
What is Array.prototype.reduce useful for?
The benefit of using reduce comes into play when you want to map and filter together and you have a lot of data to go over
What is “syntactic sugar”?
Its syntax that is designed to make reading or expressing code easier.
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
class keyword, function name curly braces constructor function parentheses, parameters curly braces this. parameter = parameter closing curly brace
What is “refactoring”?
the process of restructuring existing computer code without changing its external behavior
what is a webpack?
a static module bundler for modern JavaScript applications
How do you add a devDependency to a package?
–save-dev command input
What is an NPM script?
a way to run commands without manually typing it out?
How do you execute Webpack with npm run?
npm run build
How are ES Modules different from CommonJS modules?
es modules don’t have require function, or use the module object. they use the import/export keywords.
What kind of modules can Webpack support?
ECMAScript modules
CommonJS modules
AMD modules
What is React?
React is a declarative, efficient, and flexible JavaScript library for building user interfaces.
What is a React element?
A react element is a plain object describing a component instance or DOM node and its desired properties
How do you mount a React element to the DOM?
with the ReactDOM.render() method
What is Babel?
a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments
What is a Plug-in?
a software component that adds a specific feature to an existing computer program.
What is a Webpack loader?
transformations that are applied to the source code of a module.
How can you make Babel and Webpack work together?
with the babel loaders
What is JSX?
it is a syntax extension to JavaScript
Why must the React object be imported when authoring JSX in a module?
so they are in the same scope?
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
with babel-loader
What is a React component?
components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
How do you define a function component in React?
a single “props” (which stands for properties) object argument with data and returns a React element
How do you mount a component to the DOM?
ReactDOM.render method with the element and the location it is going to be in?
What are props in React?
properties
How do you pass props to a component?
When React sees an element representing a user-defined component, it passes JSX attributes and children to this component as a single object
How do you write JavaScript expressions in JSX?
within curly braces.
how do you create “class” components in react?
with the render method
how do you access props in a class component
use this keyword
What is the purpose of state in React?
State is an object that determines how that component renders and behaves
How to you pass an event handler to a React element?
via a prop
What Array method is commonly used to create a list of React elements?
map method
What is the best value to use as a “key” prop when rendering lists?
id
What are controlled components?
An input form element whose value is controlled by React in this way is called a “controlled component”.
What two props must you pass to an input for it to be “controlled”?
value and type
What does express.static() return?
a middleware function
What is the local __dirname variable in a Node.js module?
a path
What does the join() method of Node’s path module do?
joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
what does fetch() return
A Promise that resolves to a Response object.
What is the default request method used by fetch()?
get requests
How do you specify the request method (GET, POST, etc.) when calling fetch?
inside the init argument
When does React call a component’s componentDidMount method?
after the component is mounted
Name three React.Component lifecycle methods.
componentDidMount, componentDidUpdate componentWillUnmount render
How do you pass data to a child component?
through its props
What must the return value of myFunction be if the following expression is possible
a function
What does this code do? const wrap = value => () => value;
wrap(value) will return function () => value
wrap(value)() will return value because the second parenthesis is calling the return value of wrap(value)
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
definition time
What allows JavaScript functions to “remember” values from their surroundings?
the closure.
What does the acronym LIFO mean?
last in first out
What methods are available on a Stack data structure?
pop peek, push
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
assign the values that are being popped to a variable then peek at the value that needs to be accessed and then push the values that are assigned to a variable back into the stack
What does the acronym FIFO mean?
first in first out
What methods are available on a Queue data structure?
peek enqueue dequeue
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
dequeue to the value