Node Flashcards

1
Q

What is Node.js?

A

Node.js is a set of libraries for JavaScript which allows it to be used outside of the browser. It is primarily focused on creating simple, easy-to-build network clients and servers.

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

Node.js is designed to build scalable network applications for the back-end.

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.

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

Python, C, C++, , C#, Java, Ruby, PHP, Golang, 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

The process object is 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
7
Q

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

A

As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()

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 in JavaScript is just a file containing related code. In JavaScript, we use the import and export keywords to share and receive functionalities respectively across different modules. The export keyword is used to make a variable, function, class or object accessible to other modules.

A module is a single 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

The five values are exports, require, module, __filename, __dirname. All are available inside each module in Node.

although these parameters are global to the code within a module, they are local to the module (see documentation for module wrapper).

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
  1. process

2. console

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

module.exports are the instructions that tell Node.js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.

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

Call the local require() function and assign it to a variable

ex. 
const add = 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

Watches the task queue and the call stack. When the call stack is clear, the next thing in the task queue is pushed into the call stack.

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: The browser cannot do anything when there is blocking in the call stack. Anything that is occupying the call stack is blocking.
Non-Blocking: Allows the browser to continue the call stack even when the browser is processing code.

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

What is a directory?

A

It’s a special type of file that lists other files

17
Q

What is a relative file path?

A

A path to a file from where you are currently

18
Q

What is an absolute file path?

A

It starts from the root of the file system.

if it starts with a ‘/’ then that is the root of the file system.

19
Q

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

A

fs module

20
Q

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

A

writeFile() method of the fs object.

21
Q

Are file operations using the fs module synchronous or asynchronous?

A
Both. Every method in the fs module has synchronous as well as asynchronous forms.
Synchronous methods has 'Sync' attached at the end.