How “Control Flow” controls the functions calls?
The control flow does the following job:
- Control the order of execution
- Collect data
- Limit concurrency
- Call the next step in a program
What does Node.js TTY module contains?
The Node.js TTY module contains tty.ReadStream and tty.WriteStream classes. In most cases, there is no need to use this module directly. You have to used require (‘tty’) to access this module.
Syntax:
var tty = require(‘tty’);
Does Node.js supports cryptography?
Yes, Node.js Crypto module supports cryptography. It provides cryptographic functionality that includes a set of wrappers for open SSL’s hash HMAC, cipher, decipher, sign and verify functions.
What is error-first callback?
Error-first callbacks are used to pass errors and data. If something goes wrong, the programmer has to check the first argument because it is always an error argument. Additional arguments are used to pass data.
fs.readFile(filePath, function(err, data) {
if (err) {
//handle the error
}
// use the data object
});
What is the role of assert in Node.js?
The Node.js Assert is a way to write tests. It provides no feedback when running your test unless one fails. The assert module provides a simple set of assertion tests that can be used to test invariants. The module is intended for internal use by Node.js, but can be used in application code via require (‘assert’).
Is it possible to access DOM in Node?
No, it is not possible to access DOM in Node.
What is npm? What is the main functionality of npm?
npm stands for Node Package Manager. Following are the two main functionalities of npm:
- Online repositories for node.js packages/modules which are searchable on search.nodejs.org
- Command line utility to install packages, do version management and dependency management of Node.js packages.
What is an asynchronous API?
All the API’s of Node.js library are asynchronous means non-blocking. A Node.js based server never waits for an API to return data. The Node.js server moves to the next API after calling it, and a notification mechanism of Events of Node.js responds to the server for the previous API call.
What types of tasks can be done asynchronously using the event loop?
- I/O operations
- Heavy computation
- Anything requiring blocking
What tools can be used to assure a consistent style in Node.js?
Following is a list of tools that can be used in developing code in teams, to enforce a given style guide and to catch common errors using static analysis.
- JSLint
- JSHint
- ESLint
- JSCS