Node.js Flashcards

1
Q

what is Node.js?

A

a platform built on Chrome’s JS runtime for easily building fast and scalable network applications.Backend language built with python but mostly C++ and JS. It is for running JS.

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

primarily used for non-blocking, event-driven servers, due to its single-threaded nature. Used for traditional websites and back end API services. Make command line program using 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 an interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user. Lets you run JS in your command line. Browser console is also a REPL

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

when was Node.js created?

A

created in 2009 by Ryan Dahl. it is a runtime system for creating mostly server side applications

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

PHP, Ruby, Java, Python, C#(.NET), C++, Pascal, Visual Basic, Pearl, Go, Elixir, Elm ,Rust

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 also contains the program code and its activity. Executed by CPU 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

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

web dev is all about different programs talking to each other so if two processes are talking to each other, both of them have to be running, therefore you have to know if they are running

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

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

because it is global

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

What is JavaScript module?

A

it 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, required, and module

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

the process object, console object, global object, window object

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

its the instruction that tells Node.js which bits of code such as functions, objects, strings are needed 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
15
Q

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

A

by calling the require( ) method

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

What is the JavaScript Event Loop?

A

it is whats behind JS asynchronous programming. JS executes all operations on a single thread, but uses a few data structures

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

What is the JavaScript Event Loop?

A

it is whats behind JS asynchronous programming. JS executes all operations on a single thread, but uses a few data structures. Part of the JS run time that checks for asyncrynous call backs and puts it back on the stack when it is ready

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

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

A

blocking statements is executed sequentially one after another, while non blocking executes parallel. Blocking is the code thats on the stack. non blocking is things that are happening off the stack

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

What is a directory?

A

its a file that points to other files

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

What is an absolute file path?

A

sometimes known as the full path, it includes the complete location of the file or folder.

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

What is an absolute file path?

A

sometimes known as the full path, it includes the complete location of the file or folder.

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

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

A

writeFile method

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

Are file operations using the fs module synchronous or asynchronous?

A

it is both forms.

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

What is JSON?

A

is a syntax for serializing objects, arrays, numbers, strings, booleans, and null.

25
Q

What is JSON?

A

Stands for JS Object Notation, is a syntax for serializing objects, arrays, numbers, strings, booleans, and null.

26
Q

Why are serialization and deserialization useful?

A

in order to transfer data from one network to another

27
Q

Why are serialization and deserialization useful?

A

to convert data into bytes to save data into a hard drive. allows us to store and transmit data.

28
Q

How do you deserialize a JSON string into a data structure using JS?

A

with the JSON.parse( ) method

29
Q

What is a client?

A

service requesters

30
Q

What is a client?

A

service requesters. something that request data from a server. for example your browser. HTTPIE is a python script that makes a request

31
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

the browser sents an HTTP request to the webserver.

32
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

the get method

33
Q

What is on the first line of an HTTP request message?

A

a start line which contains 3 elements. An HTTP method(GET, PUT, POST), the request target, usually a URL, last is the protocol(which version of HTTP)

34
Q

What are HTTP headers?

A

let the client and the server pass additional information with an HTTP request or response. It consists of case insensitive name followed by a colon : then by its value.

35
Q

Is a body required for a valid HTTP message?

A

no it is not

36
Q

Is a body required for a valid HTTP message?

A

body is OPTIONAL

37
Q

What is NPM?

A

Node Package Manager. the world’s largest Software Library(Registry). consist of 3 components. 1. the website, 2. the command line interface(CLI), 3. the registry

38
Q

What is package?

A

a folder containing a program described by a package.json file

39
Q

How can you create a package.json with npm?

A

with the npm init –yes or -y command

40
Q

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

A

a dependency occurs when one package depends on another. If you need a program or depend on one such as jquery

41
Q

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

A

the package.json will update to include the added dependency. and node_modules directory will get created

42
Q

How do you add express to your package dependencies?

A

npm install command

43
Q

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

A

app.listen method

44
Q

How do you mount a middleware with an Express application?

A

using the app.use method

45
Q

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

A

the req and res objects

46
Q

What is the purpose of the Content-Type header in HTTP request and response messages?

A

to indicate the media type of the resource. It also tells the client what the content type of the returned content is. To tell the client what they are receiving and what the media type of the body is

47
Q

What does express.static() return?

A

returns function

48
Q

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

A

absolute path of file

49
Q

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

A

application/json is the Content-Type header

50
Q

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

A

it parses incoming request with JSON payloads and is based on body-parser

51
Q

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

A

it parses incoming request with JSON payloads and is based on body-parser. Use it when you want to work with a JSON object

52
Q

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

A

to indicate the desired action to be performed for a given resource

53
Q

What is Webpack?

A

it’s a module bundler and its main purpose is to bundle JS files for usage in a browser.

54
Q

How do you add a devDependency to a package?

A

you can install them in the root directory of your package with –save-dev

55
Q

What is an NPM script?

A

shell command to give a key as the command to run

56
Q

How do you execute Webpack with npm run?

A

npm run build

57
Q

How are ES Modules different from Common JS modules?

A

can use the keywords import and export

58
Q

What kind of modules can Webpack support?

A

AMD, typescript, css files, an ES2015 import