Node.js Flashcards

1
Q

What is Node.js?

A

an asynchronous event-driven JavaScript runtime

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

run JavaScript outside of a web browser to build applications.

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

a computer programming environment that takes user inputs, executes them, and returns the result.

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

When was Node.js created?

A

Initial release was May 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
Scripting Language (often interpreted)
JavaScript
Ruby
Python
PHP
Perl
Compiled Language 
C#
Java
Go
Haskell
typescript
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Questions I have:

A

What is a runtime?
- all of the stuff that surrounds your program that you didn’t write
What is a thread?
- what the cpu uses as a spot to pick up where it left off in running a program
What is dead-locking?
- when two threads are relying on each other to finish in order to execute the next step

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

What is a computer process?

A

a process is the instance of a running computer program.

While a computer program is a passive collection of instructions typically stored in a file on disk, a process is the execution of those instructions after being loaded from the disk into memory.

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

Roughly how many computer processes are running on your host operating system? (activity monitor)

A

628 processes

com.docker.hyperkit is using the most CPU

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

Since it is global you can just use its name like a variable that has already been defined

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 of strings

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

What is the 3 tierd structure of full stack web development?

A

Front end process
Back end process
Data process (at least one)

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

What is a JavaScript Module?

A

it is a single .js file.

Authors of Node.js programs strive to separate their code into modules that each provide a small chunk of functionality.

The program as a whole is the result of all these modules working together in concert.

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

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

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

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

A

process

global

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

What is the idea behind modular programming?

A

decompose a solution to a large problem into many smaller solutions to sub-problems

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

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

A

to tell which bits of code 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
18
Q

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

A

call the require function and pass in the relative file path of the module needed

19
Q

What is the JS event loop?

A

it is a way of understanding how code is executed from the stack, collecting and processing events, and executing queued sub-tasks

20
Q

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

A

non-blocking code is asynchronous code that is being executed while other code can be executed

blocking code is synchronous code that is being executed and not allowing other code to execute. Blocking code is on top of the call stack.

21
Q

What are the 4 concepts that set JS apart from other languages?

A

Prototypal Inheritance
how “this” works
closures
event loop

22
Q

What is a directory?

A

Is a special file that holds files

23
Q

What is a relative file path?

A

path that locates a file starting from the current directory

24
Q

What is an absolute file path?

A

a path from the root directory and the complete directory list required to locate the file

starts with a /

25
Q

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

A

fs module

26
Q

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

A

fs.writeFile(file, data[,options], callback

27
Q

Are file operations using the fs module synchronous or asynchronous?

A

they can be either depending on the method that is used

28
Q

What is NPM?

A

World’s largest software registry.

Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.

3 distinct components:

  • website
  • command line interface (CLI)
  • registry
29
Q

What is a package?

A

is a file or directory that has a package.json file within it.

A package must contain a package.json file in order to be published to the npm registry.

30
Q

How can you create a package.json with npm?

A

On the command line navigate to the root directory of your package

Run the command npm init –yes

31
Q

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

A

Third party code that your application depends on

npm install

32
Q

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

A

You are able to use that dependency’s code in your own

updates the dependencies within package.json

33
Q

How do you add “express” to your package dependencies?

A

use npm install express

34
Q

What Express application method starts the server and binds it to a network PORT

A

.listen( ) method

35
Q

How do you mount a middleware with an Express application?

A

using the app.use( ) method

36
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

req

res

37
Q

What are middleware functions?

A

functions that have access to the request object, the response object, and the next middleware function in the application’s request-response cycle.

38
Q

What is the appropriate “Content-type” header for HTTP messages that contain JSON in their bodies?

A

application/json

39
Q

What does the express.json( ) middleware do and when do you need it?

A

Express.json parses incoming requests with JSON payloads

Needed when you are transmitting JSON data in web applications

40
Q

What is the significance of an HTTP request’s method?

A

describe the intent of the client in what they want from the server

41
Q

What does express.static( ) return?

A

a function (middleware function)

42
Q

What is the local __dirname variable in a Node.js module?

A

the absolute path of the directory that the current module is in

43
Q

What does the join( ) method of Node’s “path” module do?

A

the path.join() method joins all given path segments together