InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What tools can be used to assure consistent code style? |
|
Answer» ESLINT can be USED with any IDE to ensure a consistent CODING style which further helps in MAINTAINING the codebase. |
|
| 2. |
What is the purpose of module.exports? |
|
Answer» This is used to expose functions of a PARTICULAR MODULE or file to be used elsewhere in the project. This can be used to encapsulate all SIMILAR functions in a file which further improves the project structure. Thus using module.exports we can use these functions in some other file: const { getSolutionInJavaScript, getSolutionInPython} = require("./utils") |
|
| 3. |
List down the two arguments that async.queue takes as input? |
| Answer» | |
| 4. |
How many types of API functions are there in Node.js? |
|
Answer» There are two TYPES of API functions:
|
|
| 5. |
How do you create a simple server in Node.js that returns Hello World? |
| Answer» VAR http = require("http");http.createServer(FUNCTION (request, RESPONSE) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n');}).listen(3000); | |
| 6. |
Why is Node.js single-threaded? |
|
Answer» Node.js was created explicitly as an EXPERIMENT in async processing. This was to TRY a new theory of doing async processing on a single thread over the existing thread-based IMPLEMENTATION of SCALING via different frameworks. |
|
| 7. |
What is fork in node JS? |
|
Answer» A fork in general is used to SPAWN child PROCESSES. In node it is used to create a new INSTANCE of V8 engine to RUN multiple workers to execute the code. |
|
| 8. |
What are the advantages of using promises instead of callbacks? |
|
Answer» The main advantage of using PROMISE is you GET an object to decide the ACTION that needs to be taken after the async task completes. This gives more manageable code and avoids CALLBACK hell. |
|
| 9. |
What are some commonly used timing features of Node.js? |
Answer»
|
|
| 10. |
Explain the steps how “Control Flow” controls the functions calls? |
| Answer» | |
| 11. |
How is Node.js better than other frameworks most popularly used? |
Answer»
|
|
| 12. |
How do you manage packages in your node.js project? |
|
Answer» It can be managed by a number of package installers and their configuration file accordingly. Out of them mostly use npm or yarn. Both PROVIDE almost all libraries of javascript with extended FEATURES of controlling environment-specific configurations. To maintain versions of libs being INSTALLED in a project we use package.json and package-lock.json so that there is no issue in PORTING that APP to a different environment. |
|
| 13. |
What is Node.js and how it works? |
|
Answer» Node.js is a virtual machine that uses JavaScript as its scripting language and runs Chrome’s V8 JavaScript engine. Basically, Node.js is based on an event-driven architecture where I/O runs asynchronously making it lightweight and efficient. It is being used in DEVELOPING desktop APPLICATIONS as well with a popular FRAMEWORK called electron as it provides API to access OS-level features such as file system, NETWORK, ETC. |
|
| 14. |
What is a first class function in Javascript? |
|
Answer» When FUNCTIONS can be treated like any other variable then those functions are first-class functions. There are MANY other programming languages, for EXAMPLE, scala, Haskell, ETC which follow this including JS. Now because of this function can be PASSED as a param to another function(callback) or a function can return another function(higher-order function). map() and filter() are higher-order functions that are popularly used. |
|