Question:- What are buffers in Node.js?
Answer:- In general, a buffer is a temporary memory mainly used by the stream to hold on to some data until it is consumed. Buffers are used to represent a fixed-size chunk of memory allocated outside of the V8 JavaScript engine. It cant be resized. It is like an array of integers, which each represents a byte of data. It is implemented by the Node. js Buffer class. Buffers also support legacy encodings like ASCII, utf-8, etc.
Question:- What is error-first callback?
Answer:- 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.
Question:- What is an asynchronous API?
Answer:- All the APIs 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.
Question:- How can you avoid callbacks?
Answer:- To avoid callbacks, you can use any one of the following options: • You can use modularization. It breaks callbacks into independent functions. • You can use promises. • You can use yield with Generators and Promises.
Question:- How can you avoid callbacks?
Answer:- To avoid callbacks, you can use any one of the following options: • You can use modularization. It breaks callbacks into independent functions. • You can use promises. • You can use yield with Generators and Promises.
Question:- Does Node.js provide Debugger?
Answer:- Yes, Node.js provides a simple TCP based protocol and built-in debugging client. For debugging your JavaScript file, you can use debug argument followed by the js file name you want to debug.
Question:- What is a control flow function?
Answer:- Control flow function is a generic piece of code that runs in between several asynchronous function calls.
Question:- How "Control Flow" controls the functions calls?
Answer:- The control flow does the following job: • Control the order of execution • Collect data • Limit concurrency • Call the next step in a program
Question:- Is it possible to access DOM in Node?
Answer:- No, it is not possible to access DOM in Node.
Question:- What types of tasks can be done asynchronously using the event loop?
Answer:- • I/O operations • Heavy computation • Anything requiring blocking
Question:- What is REPL in Node.js?
Answer:- REPL stands for Read Eval Print Loop. It specifies a computer environment like a window console or Unix/Linux shell where you can enter a command, and the computer responds with an output. It is very useful in writing and debugging the codes. REPL environment incorporates Node.js.
Question:- Explain the tasks of terms used in Node REPL.
Answer:- Following are the terms used in REPL with their defined tasks: • Read: It reads users input; parse the input into JavaScript data-structure and stores in memory. • Eval: It takes and evaluates the data structure. • Print: It is used to print the result. • Loop: It loops the above command until user press ctrl-c twice to terminate.
Question:- Is it possible to evaluate simple expressions using Node REPL?
Answer:- Yes. You can evaluate simple expressions using Node REPL.
Question:- Does Node.js supports cryptography?
Answer:- Yes, Node.js Crypto module supports cryptography. It provides cryptographic functionality that includes a set of wrappers for open SSLs hash HMAC, cipher, decipher, sign and verify functions.
