Node.js Flashcards

1
Q

What is Node.js?

A
  • An asynchronous JavaScript runtime

- A program or set of libraries 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
  • Commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform
  • It is primarily focused on creating simple, easy-to-build network clients and servers.
  • Can write client application and server applications in Node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a REPL?

A
  • Stands for “Read-Eval-Print-Loop”

- It is reads single user inputs, executes/evaluates them, and returns/prints 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

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
  • Ruby on Rails
  • Java
  • PHP
  • C++
  • C#
  • SQL
  • Perl
  • Go
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a computer process?

A
  • The instance of a computer program that is being executed by one or many threads.
  • It contains the program code and its activity.
  • It is the actual execution of the computer program instructions.
  • takes the program and runs it, starts asking for RAM
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

hundreds

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
  • Full stack Web development is based on making multiple processes work together to form one application, so having at least a cursory awareness of computer processes is necessary
  • NEED to know HTTP
  • client process sends http request to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

runtime

A
  • when the program is executed

- language environment, how your program is executed by node.js

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

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

A

global process

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

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

A

An array

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

process.argv (property)

A
  • Returns an array containing the command line arguments passed when the Node.js process was launched.
  • First element: process.execPath. (See process.argv0 if access to the original value of argv[0] is needed. )
  • Second element: the path to the JavaScript file being executed.
  • The remaining elements will be any additional command line arguments.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are real world applications for using process.argv?

A

command line processes use own process.argv

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

modular programming

A
  • breaking up into chunks and having smaller pieces of functionality
  • a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a JavaScript module?

A

a single .js file.

17
Q

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

A
\_\_dirname
\_\_filename
exports
module
require()
18
Q

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

A

process

Class: Buffer

19
Q

CommonJS

A
a project with the goal to establish conventions on the module ecosystem for JavaScript outside of the web browser. 
 module specification is widely used today, in particular for server-side JavaScript programming with Node.js.
20
Q

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

A

to store one module’s properties and methods on the module.exports to be transferred to another module

21
Q

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

A

require function

22
Q

What is the JavaScript Event Loop?

A

The process in which JS monitors the stack and callback queue. If the stack is empty, it will push tasks (if any) from the task/callback queue onto the stack

23
Q

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

A

blocking: code that is executed synchronously, code that blocks the call stack and prevents the browser from doing anything else until the process is finished

non-blocking: code that is executed asynchronously, still allows the browser to do its thing in between executing of this async code

24
Q

What is a directory?

A

special type of file that holds information about more directories and files

25
Q

What is a relative file path?

A

path to a specific file from another file (not at the root)

26
Q

What is an absolute file path?

A

absolute path starts at the root of a file

27
Q

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

A

fs module

28
Q

fs.readFile(path[, options], callback)

A
  • path | | | filename or file descriptor

- callback : err , data |

29
Q

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

A

fs.writeFile

30
Q

Are file operations using the fs module synchronous or asynchronous?

A

both!