Node.js Flashcards

1
Q

What is a CLI?

A

Command Line Interface, processes commands to a computer program in the form of lines of text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a GUI?

A

Graphical user interface, a form of user interface that allows user to interact with electronic devices through graphical icons and audio indicators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the three virtues of a great programmer?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Node.js?

A

Node.js is a set of libraries for JavaScript which allows it to be used outside of the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What can Node.js be used for?

A
  • Back end for web pages
  • Running JS outside of a browser
  • Realtime applications
  • Collaboration tools
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a REPL?

A

Simple interactive programming environment. For example, the browser console.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When was Node.js created?

A

2009, by Ryan Dahl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What back end languages have you heard of?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a computer process?

A

A computer process is an instance of a program being executed by one or more threads, containing program code and activity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

300+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why should a full stack Web developer know that computer processes exist?

A

Full stack programs server and database, communicating with each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is theprocessobject in a Node.js program?

A

A process object is a global object that provides information about and control over the current Node.js process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you access theprocessobject in a Node.js program?

A

Process is global so it may be accessed without use of “require()”m but it may also be explicitly accessed with require

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the data type ofprocess.argvin Node.js?

A

Process.argv is an array of strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a JavaScript module?

A

A JavaScript file

17
Q

What values are passed into a Node.js module’s local scope?

A
  • __dirname
  • __filename
  • Require
  • Exports
  • Module
18
Q

Give two example of truly global variables in a Node.js program.

A
  • Console
  • setInterval
  • setTimeout
19
Q

What is the purpose ofmodule.exportsin a Node.js module?

A

To allow your multiple modules to be used together and share functionality

20
Q

How do you import functionality into a Node.js module from another Node.js module?

A

Using the require function, with the module’s file path as the argument.

e.g. const add = require(‘./add’);

21
Q

What is the JavaScript Event Loop?

A

Event loop checks whether or not the call stack is empty. If it is empty, new functions are added from the event queue.

22
Q

That is different between “blocking” and “non-blocking” with respect to how code is executed?

A
  • Blocking occurs when call stack is full, currently occupying the call stack
  • Nonblocking is when tasks are popped off the call stack
23
Q

What is a directory?

A

File that contains files

24
Q

What is a relative file path?

A

A relative file path starts at the current directory

Can start with:

  • ./ or nothing (for current directory)
  • ../ (for parent directory)
25
Q

What is an absolute file path?

A

A file path that starts at the root directory

/home/dev/repos/c0821-code-solutions

26
Q

What module does Node.js include for manipulating the file system?

A

fs module (file system)

27
Q

What method is available in the Node.jsfsmodule for writing data to a file?

A

fs.writeFile()

28
Q

Are file operations using thefsmodule synchronous or asynchronous?

A

Both types are available in the Node.js documentation

29
Q

What is NPM?

A
  • NPM docs
  • NPM client, used to publish reusable-code
  • NPM Registry, database of info about packages people are sharing
30
Q

What is a package?

A
  • Directory with one or more file within it

- Has to have package.json file

31
Q

How can you create apackage.jsonwithnpm?

A

npm init -y

32
Q

What is a dependency and how to you add one to a package?

A
  • A dependency is a package that you can add to your package.json file
  • npm install ‘insertpackage’
33
Q

What happens when you add a dependency to a package withnpm?

A
  • Shows as a dependency on your package.json file

- Installs package inside of node_modules