Node intro, process, process.argv, modules, fs-read/writefile Flashcards

1
Q

What is Node.js?

A

JavaScript runtime built on Chrome’s V8 JavaScript engine

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

To build scalable network applications

Write your code in JavaScript and execute it with node

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

What is REPL?

A

Read-eval-print loop

Simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user

A program written in a REPL environment is executed piecewise

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

What is a computer process?

A

A process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity.

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

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

A

Full stack web development is based on making multiple processes work together to form one application

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

The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require()

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

It’s included in the global. You can use it any time by name.

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 JavaScript module is a example.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

__dirname
The directory of the current model

__filename
The file name of the current module

exports
A reference to the module.exports (exports a file)

module
A reference to the current module

require()
Used to import modules, JSON, and local files

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

global.process

Global.global

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

It allows other files/nodes to access the the exported function, string, variable etc

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

Const name = require(‘.module’)

Use the require function

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

What is a directory?

A

A file system cataloging structure which contains references to other computer files, and possibly other directories

A file to point to other files, a place in a file system that stores other files

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

What is a relative file path?

A

A relative file path is a folder within the current directory

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

What is an absolute file path?

A

An absolute file path is a folder or file outside the current directory

Anything that starts with a forward slash /

17
Q

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

A

The fs module

18
Q

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

A

the writeFile method

19
Q

Are file operations using the fs module synchronous or asynchronous?

A

writeFile is Asynchronous

writeFileSync is Synchronous