Node.js Flashcards
What is a CLI?
Command Line Interface, processes commands to a computer program in the form of lines of text
What is a GUI?
Graphical user interface, a form of user interface that allows user to interact with electronic devices through graphical icons and audio indicators
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 - displays content of the manual, and also specific commands
cat - prints text, and also joins text files together
ls - view contents of a directory
pwd - shows location of current directory
echo - prints text that you write after the echo command
touch - creates files
mkdir - creates directories
mv - renames or moves files (source … target)
rm - removes files and directories (need -r)
cp - copies files and directories
What are the three virtues of a great programmer?
- LAZINESS: Great efforts to reduce overall energy expenditure. Labor saving code that others will value, in addition to it begin well documented.
- IMPATIENCE: Write programs that you anticipate need for.
- HUBRIS: Write and maintain programs and other people won’t say bad things about.
What is Node.js?
Node.js is a set of libraries for JavaScript which allows it to be used outside of the browser.
What can Node.js be used for?
- Back end for web pages
- Running JS outside of a browser
- Realtime applications
- Collaboration tools
What is a REPL?
Simple interactive programming environment. For example, the browser console.
When was Node.js created?
2009, by Ryan Dahl
What back end languages have you heard of?
- JavaScript (Only one with event loop)
- PHP
- Ruby
- Python
- SQL
- Elixir
- C++
- Go
- C#
- F#
- VBA
- Clojure
- C
- Julia
- Haskell
- Pascal
- Rust
- Lisp
- Perl
- TypeScript
- Objective-C
- Swift
- Kotlin
- Scala
What is a computer process?
A computer process is an instance of a program being executed by one or more threads, containing program code and activity.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
300+
Why should a full stack Web developer know that computer processes exist?
Full stack programs server and database, communicating with each other.
What is theprocessobject in a Node.js program?
A process object is a global object that provides information about and control over the current Node.js process
How do you access theprocessobject in a Node.js program?
Process is global so it may be accessed without use of “require()”m but it may also be explicitly accessed with require
What is the data type ofprocess.argvin Node.js?
Process.argv is an array of strings
What is a JavaScript module?
A JavaScript file
What values are passed into a Node.js module’s local scope?
- __dirname
- __filename
- Require
- Exports
- Module
Give two example of truly global variables in a Node.js program.
- Console
- setInterval
- setTimeout
What is the purpose ofmodule.exportsin a Node.js module?
To allow your multiple modules to be used together and share functionality
How do you import functionality into a Node.js module from another Node.js module?
Using the require function, with the module’s file path as the argument.
e.g. const add = require(‘./add’);
What is the JavaScript Event Loop?
Event loop checks whether or not the call stack is empty. If it is empty, new functions are added from the event queue.
That is different between “blocking” and “non-blocking” with respect to how code is executed?
- Blocking occurs when call stack is full, currently occupying the call stack
- Nonblocking is when tasks are popped off the call stack
What is a directory?
File that contains files
What is a relative file path?
A relative file path starts at the current directory
Can start with:
- ./ or nothing (for current directory)
- ../ (for parent directory)
What is an absolute file path?
A file path that starts at the root directory
/home/dev/repos/c0821-code-solutions
What module does Node.js include for manipulating the file system?
fs module (file system)
What method is available in the Node.jsfsmodule for writing data to a file?
fs.writeFile()
Are file operations using thefsmodule synchronous or asynchronous?
Both types are available in the Node.js documentation
What is NPM?
- NPM docs
- NPM client, used to publish reusable-code
- NPM Registry, database of info about packages people are sharing
What is a package?
- Directory with one or more file within it
- Has to have package.json file
How can you create apackage.jsonwithnpm?
npm init -y
What is a dependency and how to you add one to a package?
- A dependency is a package that you can add to your package.json file
- npm install ‘insertpackage’
What happens when you add a dependency to a package withnpm?
- Shows as a dependency on your package.json file
- Installs package inside of node_modules