Senior Flashcards
What is a code block? What are some examples of a code block?
A code block refers to code within curly brackets. i.e. for, if, function
What does block scope mean?
block scope means that the variable defined within a block will not be accessible from outside the block.
What is the scope of a variable declared with const or let?
block scope
What is the difference between let and const?
You can update let but you can’t update const
Why is it possible to .push( ) a new value into a const variable that points to an Array?
This happens because the constant is storing a reference to the array.
How should you decide on which type of declaration to use?
Ask yourself if you’re going to need to update that variable later.
What is the syntax for writing a template literal?
Hello my name is ${variable}.
What is “string interpolation”
the ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
extracting data from arrays or objects
What is the syntax for Object destructuring?
let { property1: variable1, property2: variable2 } = object
What is the syntax for Array destructuring?
let [ x, y, z ] = array
How can you tell the difference between destructuring and creating Object / Array literals?
brackets on the left side
What is the syntax for defining an arrow function?
( ) => { }
When an arrow function’s body is left without curly braces, what changes in its functionality?
implicit returns
How is the value of this determined within an arrow function?
value of this is determined during the definition time whereas in a regular function, this is defined in call time
What is a CLI?
Command Line Interface
- processes commands to a computer in the form of lines of text
What is a GUI?
Graphical User Interface
- a form of user interface that allows users to interact with electronic devices through graphical icons
What is Node.js?
Node.js is a program that allows JavaScript to be run outside of a web browser. It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
What can Node.js be used for?
back ends for Web applications, command-line programs, any kind of automation that developers wish to perform
What is a REPL?
Read-eval-print loop
- a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user.
When was Node.js created?
2009
What back end languages have you heard of?
JavaScript, PHP, Ruby, Python, Java, Go, Node JS
What is a computer process?
a running instance of a program
Why should a full stack Web developer know that computer processes exist?
back end stuff like client side, api, and databases
What is the process object in a Node.js program?
a global object that provides information about the current working process
How do you access the process object in a Node.js program
just type process
What is the data type of process.argv in Node.js?
array of strings
What is a JavaScript module?
A single JavaScript file
What values are passed into a Node.js module’s local scope?
exports, require, module, __filename, __dirname
Give two examples of truly global variables in a Node.js program
console, process
What is the purpose of module.exports in a Node.js module?
It’s purpose is so that the function/object/array can be used in a different module (js file)
How do you import functionality into a Node.js module from another Node.js module?
require function
What is the JavaScript Event Loop?
The Event Loop is what allows us to asynchronously call functions.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
something is blocking when something is currently processing in the call stack, something that is non blocking is running but not part of the call stack like webAPIs
What is a directory?
a file system which contains references to other computer files/directories
What is a relative file path?
refers to a location that is relative to a current directory
What is an absolute file path?
always contains the root element and the complete directory list required to locate the file
What module does Node.js include for manipulating the file system?
fs module
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile( )
Are file operations using the fs module synchronous or asynchronous
asynchronous
What is NPM?
Node Package Manager
It’s a way to reuse code from other developers and also a way to share your code with them
What is a package?
The reusable code
How can you create a package.json with npm?
npm init
What is a dependency and how do you add one to a package?
When you install an npm package using npm install, you are installing it as a dependency.
npm install
What happens when you add a dependency to a package with npm?
npm will download dependencies that are listed in package.json
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
How do you mount a middleware with an Express application?
app.use
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request, response, and the next middleware function in the application’s request-response cycle
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What does the express.json( ) middleware do and when would you need it?
- it parses incoming requests with JSON payloads
- when we need to parse incoming data
What is the significance of an HTTP request’s method?
semantics, describes what we are trying to do
- express our intent
What is PostgreSQL and what are some alternative relational databases?
A relational database
- SQLite
- MySQL
What are some advantages of learning a relational database?
- they support good guarantees about data integrity
- they can store and modify data in a way that makes data corruption as unlikely as possible
- most widely used kind of database
What is one way to see if PostgreSQL is running?
- top command
- postgreSQL status
What is a database schema?
- a collection of tables
- a rule how data gets stored
- a schema defines how the data in a relational database should be organized
What is a table?
a database object that organizes and stores data in a structured format
- a list of rows
What is a row?
- a list of attributes
What is SQL and how is it different from languages like JS?
SQL is imperative vs JS is declarative
How do you retrieve specific columns from a database table?
select and from
How do you filter rows based on some specific criteria?
where clause with the category name and value name
- = operator is a comparison operator not assignment
- has to evaluate true or false
What are the benefits of formatting your SQL?
easier to read
easier to debug
What are four comparison operators that can be used in a where clause?
= != < >
How do you limit the number of rows returned in a result set?
limit clause
How do you retrieve all columns from a database table?
*
How do you control the sort order of a result set?
order by clause
How do you add a row to a SQL table?
insert into
What is a tuple?
a list of values
How do you add multiple rows to a SQL table at once?
specifying 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?
returning *
How do you update rows in a database table?
update and where clause
Why is it important to include a where clause in your update statements?
So you don’t accidentally update a large amount of your data
How do you delete rows from a database table?
delete from and where clause
How do you accidentally delete all rows from a table?
if you don’t have a where clause
What is a foreign key?
A column or multiple columns that is used to establish a link between the data in two different tables
How do you join two SQL tables?
join table using foreign key
How do you temporarily rename columns or tables in a SQL statment?
as
What are some examples of aggregate functions?
avg, count, max, min, sum
What is the purpose of a group by clause?
separate rows into groups and perform aggregate functions on those groups of rows.
What are the three states a Promise can be in?
pending, fulfilled, rejected
How do you handle the fulfillment of a Promise?
.then
How do you handle the rejection of a Promise?
.catch
What is Array.prototype.filter useful for?
filter an array based on a specific condition
What is Array.prototype.map useful for?
iterate over an array and manipulate each item into a new array
What is Array.prototype.reduce useful for?
executes a reducer function on each element of the array and returns a single output value
What is “syntactic sugar”?
syntax 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 Example { constructor( ) {
} }
What is “refactoring”?
change the structure of the code but the behavior remains the same
What is Webpack?
It’s a tool that lets you bundle your JS applications
How do you add a devDependency to a package?
–save-dev
What is an NPM script?
a convenient way to bundle common shell commands for your project
How do you execute Webpack with npm run ?
add a script and npm run (script name)
How are ES Modules different from CommonJS modules
syntax is different, ES Module syntax is part of the language, CommonJS is a community library, static vs dynamic
What kind of modules can Webpack support?
ECMAscript, CommonJS, AMD modules, and Web Assembly
What is React?
JavaScript framework for building user interfaces
What is a React element?
it is a plain object that describes what the DOM should look like
How do you mount a React element to the DOM?
ReactDOM.render( )
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
What is a Plug-in?
a software component that adds a specific feature to an existing computer program
What is a Webpack loader?
loaders are the node-based utilities built for webpack to help webpack to compile and/or transform a given type of resource that can be bundled as a javascript module.
How can you make Babel and Webpack work together?
babel-loader
What is JSX?
a syntax extension to JavaScript
Why must the React object be imported when authoring JSX in a module? (import React from ‘react’)
After Babel transformed your code which is written with JSX elements, into the React. createElement calls, you can see where React is used
- because it is used in the final code that Babel outputs
- the <h1> is actually React.createElement( )</h1>
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
jsx transform
babel loader
What is a React component?
javascript function/class that returns a react element
How do you define a function component in React?
constructor functions
How do you mount a component to the DOM?
ReactDOM.render( )
What are props in React?
props are objects passed into React components as an arguments
How do you pass props to a component?
by using attribute-like values on the react element
How do you write JavaScript expressions in JSX?
using { }
How do you create “class” component in React?
define a class that extends the Component and has a render function
How do you access props in a class component?
props property of the this object
- this.props
What is the purpose of state in React?
to represent the current situation of the component
- the values you put in state changes over time
How do you pass an event handler to a React element?
onClick={ }
How do you pass an event handler to a React element?
pass it in as props but camelCased with { } for the values
What Array method is commonly used to create a list of React elements?
map
What is the best value to use as a “key” prop when rendering lists?
unique primitive
What are controlled components?
An input form element whose value is controlled by React
What two props must you pass to an input for it to be “controlled”?
onChange, value
What does express.static( ) return?
middleware function
What is the local __dirname variable in a Node.js module?
the absolute path of the directory containing the current module
What does the join( ) method of Node’s path module do?
joins all given ‘path’ segments together and normalizes the resulting path
What does fetch( ) return?
promise
What is the default request method used by fetch( )?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
pass an init obj
When does React call a component’s componentDidMount method?
after the first successful render( )
Name three React.Component lifecycle methods.
ComponentDidMount( )
ComponentDidUpdate( )
ComponentWillUnmount( )
How do you pass data to a child component?
props
What must the return value of myFunction be if the following expression is possible?
myFunction( ) ( );
return function definition
What does this code do?
const wrap = value => ( ) => value;
an anonymous function is being defined and in the code block, another anonymous function is being defined and the return value is value and all of that is being assigned to the const variable wrap
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
when it is defined
What allows JavaScript functions to “remember” values from their surroundings?
closures