Node.js - Mosh Flashcards

1
Q

A runtime enviroment for executing Javascript code

A

Node.js

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

What do we use node.js for?

A

To build back-end services (APIs)

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

Who uses Back-end services?

A

Web Apps and Mobile Apps

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

In what year was Node.js Created?

A

2009

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

fs.readFIle ( ), http.createServer ( )

What are fs and http?

A

Objects of the node enviroment

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

What does it mean Blocking - Synchronus?

A

A single thread is assigned per client.

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

Node is non-blocking / Asynchronus by default?

A

True

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

What is the output of this code?

var message = "Hey";
console.log ( global.message );
A

undefined

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

The variables in the app.js are accesible in the global scope. True or false

A

false

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

What is considered a module?

A

A js file. Ex: app.js

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

How can I use a code outside of a module?

A

I need to export it.

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

What is the output of this code? <br></br>

console.log ( module );

A

it displays a json file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
What does this code do? <br>
function log ( ) {  code }
module.export.log = log
A

Exports the function log

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

What is the function we use in node to load a module?

A

require ( )

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

What is the Module Wrapper Function?

A

It’s a IIFE used to config the module.

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

What are the variables that the Module Wrapper Function enables?

A
  • exports
  • require
  • module
  • __filename
  • __dirname
17
Q

How do we use the node modules?

A

Using the require ( ) in our module.

18
Q

What are the core functionalities based on?

A

Events

19
Q

What does an Event indicate?

A

Indicates that something has happended in our app

20
Q

What is the convention for classes names?

A

the first letter is uppercase

21
Q
What does this code do?
const EventEmitter = require ( 'events' );
const emitter = new EventEmitter ( );
A

It loads the events node module.

And creates an instances of that class

22
Q
A class is like the person John and an object is like human.
True or False?
A

False. Opposite

23
Q
const EventEmitter = require ( 'events' );
const emitter = new EventEmitter ( );

Which is the object and which the class?

A

EventEmitter is the class.

emitter is the object.