Node.js Flashcards
What is a CLI?
Command line interface, an interface between users and a command line interpreter/processor. It takes in lines of text as commands
What is a GUI?
Graphical user interface, allows a user to interact with a computer through graphical icons (as opposed to text lines like with a CLI)
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
- Anytime you want to know about a command, pull up the manual
-
cat
- View the contents of a file
- Put the contents of multiple files into one file
-
ls
- Show the contents of a directory, either the current directory or otherwise -
pwd
- Know where you are, or output where you are to a file -
echo
- Theconsole.log
of the command line, prints something
- Quickly make a file with one line of text in it -
touch
- Make an empty file -
mkdir
- Make a directory, or directory within a directory -
mv
- Renaming a file
- moving a file -
rm
- Delete files or directories -
cp
- Make copies of files
What is Node.js?
A JavaScript runtime that is asynchronous and event driven
A runtime is “where the code gets run” and has all the stuff that handles interacting with memory, garbage collecting, interfacing with the OS, how parameters get passed, etc.
What can Node.js be used for?
They claim it is “to build scalable network applications”
JavaScript can be used to write command line tools and server-side scripting
It allows for JavaScript to be the language for both server and client side
What is a REPL?
read-eval-print-loop
Evaluates code one line at a time rather than running an entire file
Takes in user input one line at a time (read), evaluates the code (eval), and outputs the result (print), and it repeats (loop)
~Interactive shell environment
When was Node.js created?
Initial release was May 27, 2009
What back end languages have you heard of?
Scripting/interpreted: Python, JavaScript, Ruby, PHP, Perl, SQL (can’t really write a backend with this)
Compiled: C, C++, Go, Haskell, Crystal, Rust
Partially compiled: Java (JVM), Scala (JVM), clojure (JVM), kotlin (JVM), C# (.NET CLR), F# (.NET CLR), Visual Basic
What is a JavaScript module?
It is a single .js
file meant to separate out some functionality (modularized code, modular programming)
What values are passed into a Node.js module’s local scope?
module
, exports
, \_\_dirname
, \_\_filename
, require
Give two examples of_truly_global variables in a Node.js program.
-
global
process
console
- some global functions:
clearImmediate()
,clearInterval()
,clearTimeout()
,setImmediate/Interval/Timeout
- There are some global classes as well
What is the purpose ofmodule.exports
in a Node.js module?
Allow things (any data types) to be returned from a module called by require()
How do you import functionality into a Node.js module from another Node.js module?
The source module should have the desired functionality in its `module.exports` The calling module should then `require()` the source file - The return of that `require` call will be `module.exports` from the source, to then be handled however desired (likely assigned to a variable)
What is a directory?
A store of “directions” to files or other directories
A file that lists locations to other files
What is a relative file path?
A path to a file that starts/assumes a starting position of the current directory
Set of directions from current directory to there
What is an absolute file path?
A path to a file that has the entire path explicitly noted
From the root of the file system
What module does Node.js include for manipulating the file system?
The fs.js
module
What method is available in the Node.jsfs
module for writing data to a file?
fs.writeFile()
although there is also fs.write()
which does something similar with file descriptors