Node.js Flashcards
What is a CLI?
Command line interface
Text based way to talk to a program
What is a GUI?
Graphical user interface
Aimed at consumers of technology (end users)
Man (manual/directions and helpful tools)
Man man
Cat (concatenate files and prints content into terminal)
Cat filename.txt (prints the content of the file)
Cat filename.txt secondfilename.txt anotherfile.txt > new-file-with-all-three-content.txt (makes a new file with the content from the 3 files)
ls (lists all the contents of working directory)
ls (this lists the contents in the directory, but doesn’t show hidden ones that start with ‘.’)
ls -a (this lists (-a) all files, even the hidden ones)
ls -F (this lists whether the files are directories vs files by showing / after the directory name)
ls fileDirectoryName/ (this lists the files in this directory)
ls fileDirectoryName/fileName.txt
pwd (print working directory, prints the current working directory aka where are you right now)
pwd (this prints current working directory)
pwd > i-was-here.txt (this writes current working directory into a new file)
echo (repeats the text line back into the terminal, console.log for the terminal)
echo ‘Hello, World!’ (prints Hello, World! into terminal)
echo ‘Hello, World!’ > hello.txt (assigns the string into a new file)
touch (revise timestamp and create file if it doesn’t exist)
touch new-file-name.txt (makes new file)
touch workingDirectory/new-file-name.txt (creates new file in the directory)
touch parent/child/grandchild/.gitkeep (creates a new file in the grandchild directory)
mkdir (makes new directory)
mkdir parent (created a new directory named parent)
mkdir -p parent/child/grandchild (the -p option creates nested parent/child/grandchild directories)
mv (move or rename file)
mv old-directory-name new-directory-name (changes the old directory name to the new directory name)
rm (remove file or directory **permanent and no warning)
rm file-name.txt (the file is deleted/removed)
rm -r directory-name/ (the -r command removes the directory and all of its contents)
cp (copy a file)
cp file-name.txt copy-of-file-name.txt (this copies the file and makes a new file with same content)
What are the three virtues of a great programmer?
- Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
- Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
- Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.
What is Node.js?
Runs Javascript outside of a browser
Mainly used for file system access and network access (and gives up DOM access from JavaScript)
Event driven, like CSS
What can Node.js be used for?
Backends for web apps (http servers), command lines programs
What is a REPL?
Read eval print loop
Reads and evaluates the javascript code and then returns the result and then loops meaning it is ready to read code again
I.e. chrome dev tools console
When was Node.js created?
Nov 2009
What back end languages have you heard of?
Scripting languages (aka interpreted)
JavaScript, php, ruby, python, lua
JIT (just-in-time-compiled)
JavaScript
Compiled, memory-managed (with a garbage collector)
C# (clr family languages)
C#, F#, visual basic
Java, (jvm/java-virtual-machine family languages)
Kotlin, clojure, groovy,
Compiled, low-level (with no garbage collector)
C, C++, D, zig, rust
Database
Sql
What is the process object in a Node.js program?
The process object is an instance (global object, kind of like the window object for browser/front-end) of the running program
How do you access the process object in a Node.js program?
You can console log the process object into your javascript file and then run the file in the node program via command
JS file contains console.log(process);
Type in command terminal –> node jsFileName.js