Senior Side Flashcards
What is a code block? What are some examples of a code block?
{ } ; functions, loops, conditionals
What does block scope mean?
only variables within the block are avalible to use
What is the scope of a variable declared with const or let?
block scope
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?
Since the value of const is still the same array just changing the contents within
How should you decide on which type of declaration to use?
Use const first then decide if let it needed
What is destructuring, conceptually?
unpack values from array/properties into distinct variables
What is the syntax for Object destructuring?
const/let {propKeys: (new name) = objectName (from which object) }
What is the syntax for Array destructuring?
const/let [propKeys: (new name) = arrayName (from which array) ]
How can you tell the difference between destructuring and creating Object/Array literals?
Which side is the = on
What is the syntax for writing a template literal?
use ` ` and ${ } for variables (instead of concatenation)
What is “string interpolation”?
Using ${ } for variables
What is the syntax for defining an arrow function?
(parameters) => { } OR () => {}
When an arrow function’s body is left without curly braces, what changes in its functionality?
Automatically returns expression
How is the value of this determined within an arrow function?
enclosing scope; defined w/in function definition (usually at function call)
What is Node.js?
asynchronous event driven JS routine; executes JS outside the browser
What can Node.js be used for?
designed to build scalable network apps (command / http servers/clients)
What is a REPL?
Read-Event-Print loop
When was Node.js created?
2009
What is a CLI?
Command Line Interface
What is a GUI?
graphical user interface
What does the “man” command do?
the manual for other commands
What does the “cat” command do?
reads the file and can combine files
ls command?
list directory contents (-a for all -classify)
pwd command?
print name of current working directory
echo command?
display a line of text
touch command?
if it exists, update the file timestamp or else, create it
mkdir command?
make directory (-parents)
mv command?
move (rename) files
rm command?
remove files (-f force)
cp command?
copy files & directories
What is a computer process?
a process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity.
What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process.
How do you access the process object in a Node.js program?
process.argv[]
What is the data type of process.argv in Node.js?
An array
What is a JavaScript module?
seprate JavaScript files
What values are passed into a Node.js module’s local scope?
__dirname, __filename, exports, module, require()
What is the purpose of module.exports in a Node.js module?
export code (a module) to another file; make avalible to other modules
How do you import functionality into a Node.js module from another Node.js module?
require()
What is the JavaScript Event Loop?
takes callbacks from callback que & puts it back into the stack after everything else has ran
What is different between “blocking” and “non-blocking” with respect to how code is executed?
how code sits in the stack. Blocking need to finish before other can run. Non-blocking runs after the stack is clear
What is a directory?
file system (folder)
What is a relative file path?
points to a file relative to the page
What is an absolute file path?
a full URL to a different file
What module does Node.js include for manipulating the file system?
‘fs’
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?
both
What is NPM?
software registry; website, CLI, registry
What is a package?
module/file in a directory that can be added to your file and utilized
How can you create a package.json with npm?
mpm init -y
hat is a dependency and how to you add one to a package?
nmp install _____
What happens when you add a dependency to a package with npm?
node_modules directory gets created w/ fs
How do you add express to your package dependencies?
- nmp init -y
2. nmp install express
What Express application method starts the server and binds it to a network PORT?
app.listen(3000, )
How do you mount a middleware with an Express application?
app.use(path, callback)
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req & res
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What is the significance of an HTTP request’s method?
semantic
What does the express.json() middleware do and when would you need it?
mount the middleware; need it to get json body from client
What is a database schema?
collection of tables
What is a table?
a list of rows
What is a row?
data with the same attribute
What is one way to see if PostgreSQL is running?
Use the top command
What is a foreign key?
a column (attribute) that has the same values on separate tables (unique identifier)
How do you join two SQL tables?
join “tableName” using (“foreignKey”)
How do you temporarily rename columns or tables in a SQL statement?
using the “as” keyword
How do you delete rows from a database table?
using the “delete” keyword with the table name
How do you accidentally delete all rows from a table?
not including the “WHERE” clause
How do you update rows in a database table?
using the “UPDATE” clause
Why is it important to include a where clause in your update statements?
So you do not change every single row (the entire column)
How do you add a row to a SQL table?
using the “INSERT” clause
What is a tuple?
values for the corresponding attributes
How do you add multiple rows to a SQL table at once?
use multiple tuples separated by commas
How to you get back the row being inserted into a table without a separate select statement?
use the “returning *”
What is Array.prototype.reduce useful for?
to take an array and create a single value by combining the array
What is Array.prototype.map useful for?
creates a new array populated w/ results of callback function going through each element of the array
What is Array.prototype.filter useful for?
creates a new array w/ elements that pass the test implemented by the callback function
What is “syntactic sugar”?
syntax designed to make things easier to read/express
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
class keyword { }
What is “refactoring”?
restructuring exisiting code w/out changing the external behavior
What is Webpack?
Writes modules & supports any module format & handles resources & assests
How do you add a devDependency to a package?
using –save-dev (or -D) when installing with npm
What is an NPM script?
Inside the package.json; properties store so reference in the terminal
How do you execute Webpack with npm run?
add build to the package.json and the npm run build in the terminal
How are ES Modules different from CommonJS modules?
uses imports and export (export default for one fucnction/class per file) and
What kind of modules can Webpack support?
ECMA Script Modules, CommonJS Modules, AMD Modules, assests, Web Assebly Modules
What is React?
JS library for building user interfaces
What is a React element?
describes what you want to see on the screen (ex: const element = <h1> Hello </h1>)
How do you mount a React element to the DOM?
Using the React.createElement( )
What is Babel?
a JS complier (converts new JS syntax into older JS syntax)
What is a Plug-in?
not needed for program to run, but can be added in addition to customize
What is a Webpack loader?
allow you to pre-process files as you import/load them; can transform files from a diff language to JS
How can you make Babel and Webpack work together?
installing the bable-loader
What is JSX?
syntax extension to JS tha allows us to write HTML; JSX produces react “elements”
Why must the React object be imported when authoring JSX in a module?
When using JSX we are calling on methods from React; JSX tags = React.createElement( )
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
install bable loader and the extra plugin
What is a React component?
a function/class
How do you define a function component in React?
regular JS function except the name must be capitalized
How do you mount a component to the DOM?
using the react.render( )
What are props in React?
act as attributes in JSX files; similar to an argument in JS
How do you pass props to a component?
using props as a parameter
How do you write JavaScript expressions in JSX?
write a function with the name capitalized
How do you create “class” component in React?
class keyword, extends React.Component, { }, render( ),
How do you access props in a class component?
using the “this” object
What is the purpose of state in React?
Save for future reference; keep track of values that change over time
How to you pass an event handler to a React element?
needs to start with on / as a prop / with camel case; render( ) gets element from return value
What are controlled components?
takes its current value through props and notifies changes through callbacks like onChange
What two props must you pass to an input for it to be “controlled”?
props (value) and state (change)
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?
a string that is an unique identifier (usually an id prop)
What does express.static( ) return?
middleware function
What is the local __dirname variable in a Node.js module?
a string of the directory name of the current module
What does the join( ) method of Node’s path module do?
joins all given path segments ((hello, hi) -> /hello/hi)