Node.js - Mosh Flashcards
A runtime enviroment for executing Javascript code
Node.js
What do we use node.js for?
To build back-end services (APIs)
Who uses Back-end services?
Web Apps and Mobile Apps
In what year was Node.js Created?
2009
fs.readFIle ( ), http.createServer ( )
What are fs and http?
Objects of the node enviroment
What does it mean Blocking - Synchronus?
A single thread is assigned per client.
Node is non-blocking / Asynchronus by default?
True
What is the output of this code?
var message = "Hey"; console.log ( global.message );
undefined
The variables in the app.js are accesible in the global scope. True or false
false
What is considered a module?
A js file. Ex: app.js
How can I use a code outside of a module?
I need to export it.
What is the output of this code? <br></br>
console.log ( module );
it displays a json file
What does this code do? <br> function log ( ) { code } module.export.log = log
Exports the function log
What is the function we use in node to load a module?
require ( )
What is the Module Wrapper Function?
It’s a IIFE used to config the module.
What are the variables that the Module Wrapper Function enables?
- exports
- require
- module
- __filename
- __dirname
How do we use the node modules?
Using the require ( ) in our module.
What are the core functionalities based on?
Events
What does an Event indicate?
Indicates that something has happended in our app
What is the convention for classes names?
the first letter is uppercase
What does this code do? const EventEmitter = require ( 'events' ); const emitter = new EventEmitter ( );
It loads the events node module.
And creates an instances of that class
A class is like the person John and an object is like human. True or False?
False. Opposite
const EventEmitter = require ( 'events' ); const emitter = new EventEmitter ( );
Which is the object and which the class?
EventEmitter is the class.
emitter is the object.