Node.js Flashcards

1
Q

What is Node.js?

A

A runtime environment used for executing JavaScript code on the SERVER-SIDE, instead of in the browser.

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

What is an engine?

A

An engine is what processes our code and makes it do something in the browser.

The engine is what makes it possible for a computer to understand human readable code such as JavaScript.

Google Chrome = V8 JavaScript engine; Mozilla Firefox = SpiderMonkey;
Apple Safari = JavaScriptCore;

The engine also decides how it processes our code, e.g compiles, interprets or JIT’s our code

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

What relevance does ECMAScript (ES) have to an engine?

A

ECMAScript is the standard regulations that the browser engines comply with so they know how to interpret and execute your code.

JavaScript is an implementation of the ECMAScript standard.

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

What is an environment?

A

The browser is what we call an environment.

This is where our code is being executed, and USUALLY the engine is a part of the browser environment. (Node.js does not do this!)

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

What engine does Node.js use?

A

Both your browser, JavaScript & Node.js run on the Chrome V8 JavaScript runtime engine.

This engine takes your JavaScript code and converts it into a faster machine code.

Machine code is low-level code which the computer can run without needing to first interpret it.

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

What is a runtime environment?

A

A runtime environment is the where the code is processed (by the engine) & executed.

So with Node.js:

  • The server = environment
  • Runtime = when the code is running
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is meant by Asynchronous API?

A

All APIs of Node.js library are aynchronous that is non-blocking.

A Node.js based server never waits for a API to return data.

The server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

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

What are the benefits of using Node.js

A

Aynchronous and Event Driven

Very Fast
- Google Chrome’s V8 JavaScript Engine is the fastest at interpreting JS code, which = super fast code execution

Single Threaded but highly Scalable

No Buffering
- data is outputted in chunks

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

What is an error-first callback?

A

Error-first callbacks are used to pass errors and data.

The first argument is always an error object that the programmer has to check if something went wrong.

Additional arguments are used to pass data.

E.G.

fs.readFile(filePath, function(err, data) {
  if (err) {
    // handle the error
  }
  // use the data object
})
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Different between Node & AJAX

A

???

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

What are Event Listeners?

A

Node.js has built in event’s and built in event listeners. Node.js also provides functionality to create Custom events and Custom Event listeners.

They are similar to call back functions, but are associated with some event.

E.G. when a server listens to http request on a given port, an event will be generated to specify the HTTP server has received it & will invoke corresponding event listener.

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