Node.js Flashcards

1
Q

What is a CLI?

What is a GUI?

A

command line interface

graphical user interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
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 - manual
cat - read files and “concatenate files”
ls - list files – options -aF to show all and any files starting with .
pwd - print working directory
echo - echos a string
touch - alters a file or directory - make blank file
mkdir - make directory – options -p to include parent directories
mv - move or rename files
rm - remove files –> rm -r remove directory -f force
cp - copy file

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

What is Node.js?

A

asynchronous event-driven JavaScript runtime

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

What can Node.js be used for?

A

used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services

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

What is a REPL?

A

read, evaluate, print, loop

where you can do calculations and stuff in a ‘terminal’

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

When was Node.js created?

A

2009

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

What is the process object in a Node.js program?

A

global variable 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
8
Q

How do you access the process object in a Node.js program?

A

type process in node command

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

What is the data type of process.argv in Node.js?

A

strings in an array

–> string array

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

What is a JavaScript module?

A

smaller JS files that do a specific thing and put together to do “somethign” as a whole

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

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

A

exports, require, module, __filename, __dirname

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

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

A

process and global, console

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

What is the purpose of module.exports in a Node.js module?

A

allows the function to be import as module using require

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

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

A

require()

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

What is the JavaScript Event Loop?

A

consists of stack, heap, and queue

code is put through a stack and uses last in first out to return functions/modules, if there is any async functions/ http requests then it goes to the heap and then once it checks out it goes to the queue. Once the stack is empty it then puts the first item from the queue to the stack then returns it

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

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

A

blocking is when code “blocks” the other code because the compiler waits until that blocker code completes,

non-blocking is when code runs async and gets placed on a heap then a queue to return once a stack is cleared

17
Q

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

A

.readFile

18
Q

What method is available in the Node.js fs module for writing data to a file?

A

fs.writeFile

19
Q

Are file operations using the fs module synchronous or asynchronous?

A

async

20
Q

npm stands for

A

node package manager

21
Q

what is a package

A

directory with files with a package json

22
Q

How can you create a package.json with npm?

A

npm init –yes

23
Q

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

What happens when you add a dependency to a package with npm?

A

a dependency is a code that project needs and “depends on” like a library if you use MATH.__()

you can add to a package using npm install “package”

when a dependency gets added it is added to package.json