Senior Side Flashcards
What is a code block? What are some examples of a code block?
is code contained within { }. If else, for, while, function code blocks, etc
What does block scope mean?
variable defined exclusively within a block and cannot be accessed from outside the block
What is the scope of a variable declared withconstorlet?
block scope
What is the difference betweenletandconst?
let: is similar to var in that the value can be reassigned.
const: can not be reassigned and cannot be redeclared within the same scope
Why is it possible to.push()a new value into aconstvariable that points to anArray?
because you aren’t reassigning a variable you are adding to it, essentially you are telling it to store more information.
How should you decide on which type of declaration to use?
if the variable can be reassigned use let, if the variable is something that you may not want to change and will be reused to avoid accidentally reassigning that variable use const
What is the syntax for writing a template literal?
back ${variable} ticks
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions.
What is the syntax for defining an arrow function?
() optional parameters => optional {} expression to return
When an arrow function’s body is left without curly braces, what changes in its functionality?
it has a implicit return expression (can’t have any statements)
How is the value ofthisdetermined within an arrow function?
The value of this in an arrow function is determined when the arrow function is being defined.
What is a GUI?
Graphical User Interface
is a form ofuser interfacethat allowsuserstointeract with electronic devicesthrough graphicaliconsand audio indicator such as primary notation, instead oftext-based user interfaces, typed command labels or text navigation.
Give at least one use case for each of the commands:
man cat ls pwd echo touch mkdir mv rm cp
man (manual)
cat (concatenate files and print on the standard output)
Ls (list directory contents)
pwd (print name of current/working directory)
echo (display a line of text)
touch (create file, change file timestamps)
mkdir (make directories)
mv (move (rename) files)
rm (remove files or directories)
cp (copy files and directories)
What are the three virtues of a great programmer?
laziness, impatience, hubris
What is Node.js?
Node.js is a program that allows JavaScript to be run outside of a web browser.
What can Node.js be used for?
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 is a REPL?
read–eval–print loop
also termed aninteractive toplevelorlanguage shell, is a simple interactivecomputer programmingenvironment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.
When was Node.js created?
May 27th, 2009
What back end languages have you heard of?
Python Php Ruby Java c++ c# Rust Golang Perl Visual basic Elixir Haskell C Clojure Kotlin Wasm
What is theprocessobject in a Node.js program?
global variable that provides information about node
How do you access theprocessobject in a Node.js program?
console.log(process)
What is the data type ofprocess.argvin Node.js?
array of strings
What is a JavaScript module?
its a single JavaScript file
What values are passed into a Node.js module’s local scope?
__dirname : The directory name of the current module.
__filename : The file name of the current module.
exports : A reference to themodule.exportsthat is shorter to type.
module : A reference to the current module
require() : idmodule name or path
Returns:exported module content
Used to import modules,JSON, and local files.
Give two examples oftrulyglobal variables in a Node.js program.
global, process, console
What is the purpose ofmodule.exportsin a Node.js module?
to export the file to be used elsewhere make functionality or values available to other modules.
How do you import functionality into a Node.js module from another Node.js module?
use the require function and use the relative path to another module as the argument
What is the JavaScript Event Loop?
the order in which the javascript file is processed.
- waits for the call back to be cleared before pushing it on to the stack
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking blocks future code from being executed
blocking is on the stack and blocks anything else
synchronous code is block, asynchronous is non-blocking
What is a directory?
a file that contains files or additional directories
What is a relative file path?
s a link to a file within the same file system / directory
What is an absolute file path?
exact location of a file starting from the root
What module does Node.js include for manipulating the file system?
fs module
What method is available in the Node.jsfsmodule for writing data to a file?
writeFile()
Are file operations using thefsmodule synchronous or asynchronous?
YES
What is a client?
A user or server requesting a service
What is a server?
Something that provides a service. Receives requests and sends responses (almost always refers to a computer program/process)
Technical term for the hardware (HOST) (servers are the programs running on the hosts)
Which HTTP method does a browser issue to a web server when you visit a URL?
get()
What is on the first line of an HTTPrequestmessage?
HTTP Method
URL (request target)
HTTP protocol version (almost always 1.1)
What is on the first line of an HTTPresponsemessage?
Theprotocol version, usuallyHTTP/1.1.
Astatus code, indicating success or failure of the request. Common status codes are200,404, or302
Astatus text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.
What are HTTP headers?
META data
Is a body required for a valid HTTP message?
No
What is NPM?
Node Package Manager
is a software registry
- a large public database of JavaScript software and the meta-information surrounding it.
The website The CLI Registry
What is a package?
directory contains package.json
How can you create apackage.jsonwithnpm?
npm init - -yes
What is a dependency and how to you add one to a package?
a library that a project needs to function effectively