nodejs Flashcards

1
Q

What is Node.js?

A

open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside 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

executing javascript code outside of the web browser

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 and basically provides a programmer with an interactive programming environment

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

When was Node.js created?

A

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

node.js

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

What is a computer process?

A

instance of a computer program being executed by one or more threads

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

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

A

529 processes, 2079` threads

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

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

A

web dev 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
9
Q

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

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
10
Q

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

A

process object or using require, i.e.,

the process object itself:
console.log(process)

or

assigning a variable to the require method of the object:
const process = require('process')
console.log(process)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

string

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

What is a JavaScript module?

A

a single js file, i.e., splitting JavaScript programs up into separate “modules” that can be imported when needed

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

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

A

Variables local to the module will be private, because the module is wrapped in a function by Node.js (see module wrapper)

filename, dirname

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

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

A

exports, require

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

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

A

exports a file, i.e.,

module.exports.hello = () => { return ‘hello’; }

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

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

A

using the require keyword, i.e.,

require(‘./name-of-that-is-using-module-exports’)

17
Q

What is a directory?

A

collection of folders, files, etc

technically a “folder”

18
Q

What is a relative file path?

A

local file path, i.e.,

./assets/images/hi.jpeg

linking to something on the same server

19
Q

What is an absolute file path?

A

global file path, i.e.,

a domain (https://google.com)

usually has a protocol before like ‘http’, ‘https’. ‘ftp’, ‘file’

linking to something on a different server

20
Q

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

A

fs/promises API which provides asynchronous file system methods that return promises

21
Q

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

A

fs.writeFile

22
Q

Are file operations using the fs module synchronous or asynchronous?

A

depends; the fs module itself has options to perform a given task async (usually denoted by callback functions and the lack of the sync keyword) or sync (usually denoted by the ‘sync’ keyword, i.e., syncaccess, writefilesync)

sync blocks the event loop saying perform this task first before anything else; makes the cpu wait

async is performant

aka The fs module is unique compared with other I/O modules (like net and http) in that it has both asynchronous and synchronous APIs - means that it provides a mechanism to perform blocking I/O