JavaScript - Senior Flashcards
What is a code block? What are some examples of a code block?
within { } Loops / Functions / Conditionals
What does block scope mean?
Within that code block only
What is the scope of a variable declared with const or let?
Within that code block only
What is the difference between let and const?
const is a value which you do not plan on changing, let is a variable which you plan to change
Why is it possible to .push() a new value into a const variable that points to an Array?
Because the name is constant, not the contents
How should you decide on which type of declaration to use?
Favor const, unless you plan to reuse the variable
What is destructuring, conceptually?
Taking properties from an object or values from an array and assigning them to variables
What is the syntax for Object destructuring?
const { property list } = obj
What is the syntax for Array destructuring?
const [var 1, var2] = array
How can you tell the difference between destructuring and creating Object/Array literals?
Literals: const name = { } Destructure: const { } = name
What is the syntax for defining an arrow function?
( ) if 0 args or 2 +, => { } / sometimes optional
When an arrow function’s body is left without curly braces, what changes in its functionality?
Needs to be an expression. Will return that expression
How is the value of this determined within an arrow function?
At definition time. Will exit any arrow functions and look outside of those
What is Node.js?
An asynchronous JavaScript runtime where many connections can be handled concurrently.
What can Node.js be used for?
Back-end, Command-line app, or any kind of automation that developers wish to perform.
What is a REPL?
Read eval print loop, like a console, it prints any expression given
When was Node.js created?
2009
What back end languages have you heard of?
Ruby PHP Java C# Python C C++ Swift (not common for back end though feasible) Objective C (not common for back end though feasible) JavaScript Perl Go Erlang Elixir
What is a CLI?
Command Line Interface
What is a GUI?
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
man = manuals cat = printing contents of a file ls = lists the folders and files pwd = prints the current directory echo = prints touch = creates a file if it doesn't exist mkdir = makes a directory mv = moves or renames directory rm = remove file or directory cp = copy a file
What is a computer process?
The execution of instructions
Why should a full stack Web developer know that computer processes exist?
To be able to tie things together
What is the process object in a Node.js program?
An object that contains info about a node process
How do you access the process object in a Node.js program?
process / globally available
What is the data type of process.argv in Node.js?
array of strings
What is a JavaScript module?
a single JS 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.
global / process
What is the purpose of module.exports in a Node.js module?
This is what the module returns when being called with require / Alternatively you can use a named export (exports.add)
How do you import functionality into a Node.js module from another Node.js module?
require( path )
What is the JavaScript Event Loop?
It controls the Queue and puts things back onto the stack
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking means that nothing else can take place during this request, while non-blocking means that it sends it off and other things can happen in the meantime
What is a directory?
folder
What is a relative file path?
doesn’t start with /
What is an absolute file path?
starts with slash, at the root
What module does Node.js include for manipulating the file system?
fs
What is NPM?
CLI for sharing code / Website / Registry
What is a package?
A folder that has at least one file with a package.json file
How can you create a package.json with npm?
npm init –yes
What is a dependency and how do you add one to a package?
npm install name…
What happens when you add a dependency to a package with npm?
it adds it to your package.json and it downloads it into the node modules folder
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( )