Node.js Flashcards

1
Q

what is Node.js?

A

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. (that comes with libraries)

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 primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional web sites and back end API services, but was designed with real-time, push-based architectures in mind.

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

what is REPL?

A

A read–eval–print loop, 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.

waits for another input.. ex) browser console

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++, Java, PHP, Ruby on rails, Go etc

scripting language (often interpretted)
compile language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
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.
Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.

answer : it is the instance of a running program

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

14? the rest of em are sleeping

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.

This will be extremely important when learning about applications made of multiple components, such as clients, servers, and databases.

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

The process object in Node. js is a global object that can be accessed inside any module without requiring it.

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

its global so you don’t need the require method. just access itself.

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

array

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

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

exports, require, module, __filename, and __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

global and process

(similar to window, can control the process. the difference is, if you create the global object is the property of the window object)

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

Module exports are the instruction that tells Node.js which bits of code (functions, objects, strings etc) to “export” from a given file so other files are allowed to access the exported code.

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

by using the require function

17
Q

What is the JavaScript Event Loop?

A

JavaScript has a runtime model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. This model is quite different from models in other languages like C and Java.

18
Q

What is the JavaScript Event Loop?

A

JavaScript has a runtime model based on an event loop,
which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks.
This model is quite different from models in other languages like C and Java.

19
Q

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

A

Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes. This happens because the event loop is unable to continue running JavaScript while a blocking operation is occurring. (performed when its on the stack)

Non blocking doesn’t have to wait and move on to the other task which is asyncronous. (performed off of the stack, anywhere but not the stack )

20
Q

What is a directory?

A

special type of file with lists of file

21
Q

what is relative file path?

A

Relative Path is the hierarchical path that locates a file or folder on a file system starting from the current directory.

22
Q

what is absolute file path?

A

An absolute path always contains the root element and the complete directory list required to locate the file.

23
Q

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

A

With Node. js, you can programmatically manipulate files with the built-in fs module. The name is short for “file system,” and the module contains all the functions you need to read, write, and delete files on the local machine.

24
Q

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

A

writeFile();

25
Q

Are file operations using the fs module synchronous or asynchronous?

A

fs module has different operations for file handling such as read files, write files, append files, close files, delete files, etc. All the operations can be performed in a synchronous as well as in an asynchronous approach depending on the user requirements.

26
Q

what is npm?

A

node package manager.

use npm to share and borrow packages and many organizations use npm to manage private development as well

website, CLI, registry (database)

27
Q

what is a package?

A

A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer.

package.json is a npm package
package = directory + package.json

28
Q

How can you create a package.json with npm?

A

‘npm init –yes’ at the root directory where you wanna make the package.json

29
Q

What is a dependency and how to you add one to a package?

A

A dependency in programming is an essential functionality, library or piece of code that’s essential for a different part of the code to work

‘npm install ‘

npm install jquery@latest

30
Q

What happens when you add a dependency to a package with npm?

A

It adds to the node modules

and adds to the package.json - dependencies property