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 is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.

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

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a 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.

Takes input, evaluates it, prints output, and goes back to beginning like the console.

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

When was Node.js created?

A

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

Ruby, Python, PHP, C++, JavaScript, C, java, C#

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

What is a computer process?

A

A program that is running on your computer. This can be anything from a small background task, such as a spell-checker or system events handler to a full-blown application like Internet Explorer or Microsoft Word. All processes are composed of 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

A lot.

540 on mine.

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

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

A

The process object is the global object in Node. It can be accessed from anywhere; it is an instance of EventEmitter. Each Node.js has a set of built-in functionality, accessible through the global process object.

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

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

A

It is global so you can just type it.

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

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

A

Array of strings.

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

What is a JavaScript module?

A

In JavaScript, a “module” is a single .js file.

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

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

A
\_\_dirname
\_\_filename
exports
module
require( )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

process and console.

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

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

A

To export some code to another Node.js module.

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

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

A

const variable = require(file-path)

Ex:
const addFunction = require('./add');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the JavaScript Event Loop?

A

The JavaScript event loop is basically an endless loop, which keeps on checking whether there is something to be executed in the call stack. If the call stack is empty it checks the Event Queue, whether there is something to move to the call stack.

17
Q

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

A

“blocking”: waits for execution to complete before moving to the next call-stack. Synchronous

“non-blocking”: does not wait for execution to complete before moving the the next call-stack. Asynchronous

18
Q

What is a directory?

A

Folder/collection for files.

19
Q

What is a relative file path?

A

The path with reference to current directory.

20
Q

What is an absolute file path?

A

The path with reference to the root directory.

21
Q

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

A

fs

22
Q

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

A

fs.writeFile

23
Q

Are file operations using the fs module synchronous or asynchronous?

A

Both synchronous and asynchronous

readfile and readfile sync

24
Q

How are ES Modules different from CommonJS modules?

A

Their syntax is even more compact than CommonJS’s.
Their structure can be statically analyzed (for static checking, optimization, etc.).
Their support for cyclic dependencies is better than CommonJS’s.

Use import instead of require
Use export instead of module.exports