w2 Flashcards

1
Q

purpose of MEAN

A

purpose is to use only JS to cover diff parts of applications

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

Advantage of MEAN

A
  1. single language throughout app

2.supports MVC architecture

  1. Data marshalling using JSON objects- transforming the memory representation of an object into another format, which is suitable for storage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Node.js

A

For browser
two-way comm b/w browser and server

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

JS- event driven language meaning?

A
  • event-driven language- register code to events, code executed when event is executed- allows async programming -single thread aka event loop - when there is event created sent to event queue - sends task to event handler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why node.js?

A

Node.js eliminates the waiting and continues with the next request. Node.js runs single-threaded, non-blocking, asynchronously programming, which is very memory efficient.

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

node.js syntax, data types?

A

Similar to front end JS

Six data types that are primitives:

Boolean

Null

Undefined

Number

String

Symbol (new in ECMAScript 2015)

and Object

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

What is JS primary design flaw?

A

design flaws is the sharing of a single global namespace

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

Built-in modules Node.js

A

Node.js has a set of built-in modules that can be used without further installation

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

to export?

A

module.exports = Student;
class name

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

to import?

A

To import a package, you have to use the required keyword

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

define properties of appplication in node.js?

A

package.json->specify the version of your current release, the name of your application, and the main application file.

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

how to create new package.json file?

A

npm init

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

express?

A

added in package.json as dependency
in node_modules file too

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

HTTP ?

A

HTTP is the abbreviation of “HyperText Transfer Protocol”.

The HTTP server is the program that serves data to clients using the HTTP protocol.

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

HTTP works?

A

client sends request to server

server accepts the request and generates a response using its local database or files

the server sends back its response to the client

the client’s browser displays/renders the response

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

What is the HTTP.createServer() method?

A

The http.createServer() method turns your computer into an HTTP server by creating a HTTP Server object.

17
Q

What can the HTTP.createServer() method do?

A

The HTTP Server object can listen to ports on your computer and execute a function, a request listener, each time a request is made.

18
Q

createServer method?

A

requires a callback method (i.e. requestListener) as an input parameter

with each new request, the callback method will be invoked and provided with two parameters: request and response

19
Q

Request object?

A

using the request object, you can get details about the coming request such as the method, URL, headers, and body of the request

20
Q

Response object?

A

the response object contains many useful methods for sending data back to the client

21
Q

res.writeHead()?

A

The argument of the res.writeHead() method is the status code, 200 means that all is OK, 404 is page not found

22
Q

fs Node.js?

A

fs: the Node.js file system module allows you to work with the file system on your computer.

23
Q

fs callback?

A

The callback is passed two arguments (err, data), where data is the contents of the file

24
Q

Query string?

A

Is the part of a URL containing data that does not fit conveniently into a hierarchical path structure. For example:

http://example.com/over/there?name=Tim&age=20

starts with a question mark character (?)

Parameters are key-value pairs that can appear inside the URL path

Query string appears after the path (if any)

multiple query parameters are separated by the ampersand, “&”

25
Q

How to split the query string into readable parts in Node.js?

A

using a function called ‘parse’, which is part of the ‘url’ module

‘searchParams’ returns an object representing the query parameters of the URL.

use the 'get' to extract the value of a given key
26
Q

URL routing

A

changing file when pathname changes

27
Q

http.createServer(function (request, response) {
//….
}

If a server wants to respond to a client’s request by a string, it has to use:

A

response.write() method

28
Q

https://monash.edu:8900/fit/fit2095/?q=2&mark=10

Identify the following:

The query string
The protocol
The port number
The pathname
The server address
A

The query string- ?q=2&mark=10
The protocol- https://
The port number- 8900
The pathname- /fit/fit2095/
The server address- monash.edu

29
Q

string to int?
int to string?

A

parseInt
.toString()