Node.js Flashcards

1
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser.

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

What can Node.js be used for?

A

It can be used to build back ends for Web applications, command-line programs, or any kind of automation.

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

What is a REPL?

A

Read-eval-print loop
a simple computer programing environment that takes single user inputs, executes them, and returns the result to the user.

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

When was Node.js created?

A

It was created May 27, 2009

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

What back end languages have you heard of?

A

Python,
Java
JavaScript

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

What is the process object in a Node.js program

A

Gives control over current Node process and data model

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

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

A

call it! or require() it

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

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

A

an array of strings

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

What is a JavaScript module?

A

A module is a js file

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

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

A

process object

console object

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

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

A

The purpose of module.exports is to allow the functionality defined in modules within other modules.

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

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

A

you use the require function and pass in the file you want to import as a string argument and assign that to a variable

require(‘./add’)

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

What is the JavaScript Event Loop?

A

It monitors the queue and pushes the first thing on it onto the call stack as soon as it’s clear

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

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

A

blocking is “slow” code, nothing else can be done with blocking code

if something is occupying the call stack, it is blocking

asynchronous is non blocking

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

What is a directory?

A

A directory is a hub of the paths or references to other computer files
“folder”

17
Q

What is a relative file path?

A

A relative path takes you from where you are to another file

18
Q

What is an absolute file path?

A

An absolute file path takes you from the root of the file system to the file

19
Q

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

A

the fs module

20
Q

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

A

fs.writeFile()

21
Q

Are file operations using the fs module synchronous or asynchronous?

A

all file system operations have synchronous, callback, and promise-based forms