parent
932896c3af
commit
d66d4bcb8a
2 changed files with 95 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||||
|
CommonJS and ES Modules are two different module systems in JavaScript. CommonJS is the module system used in Node.js, while ES Modules are the module system used in browsers and TypeScript. |
||||||
|
|
||||||
|
## CommonJS |
||||||
|
|
||||||
|
```js |
||||||
|
const fs = require('fs'); |
||||||
|
``` |
||||||
|
|
||||||
|
CommonJS modules are loaded synchronously. This means that the module is loaded and evaluated before the code using the module is executed. It uses `require()` to load modules and `module.exports` to export modules. |
||||||
|
|
||||||
|
## ES Modules |
||||||
|
|
||||||
|
```js |
||||||
|
import fs from 'fs'; |
||||||
|
``` |
||||||
|
|
||||||
|
ES Modules are loaded asynchronously. This means that the module is loaded and evaluated when the module is used. It uses `import` to load modules and `export` to export modules. |
@ -0,0 +1,78 @@ |
|||||||
|
--- |
||||||
|
order: 1 |
||||||
|
briefTitle: 'Node.js' |
||||||
|
briefDescription: 'Test, rate and improve your Node.js knowledge with these questions.' |
||||||
|
title: 'Node.js Questions' |
||||||
|
description: 'Curated list of Node.js questions to test, rate and improve your knowledge. Questions are based on real world experience and knowledge.' |
||||||
|
isNew: true |
||||||
|
seo: |
||||||
|
title: 'Node.js Questions' |
||||||
|
description: 'Curated list of Node.js questions to test, rate and improve your knowledge. Questions are based on real world experience and knowledge.' |
||||||
|
keywords: |
||||||
|
- 'node.js quiz' |
||||||
|
- 'node.js questions' |
||||||
|
- 'node.js interview questions' |
||||||
|
- 'node.js interview' |
||||||
|
- 'node.js test' |
||||||
|
sitemap: |
||||||
|
priority: 1 |
||||||
|
changefreq: 'monthly' |
||||||
|
questions: |
||||||
|
- question: What is Node.js? |
||||||
|
answer: Node.js is an open-source and cross-platform JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Beginner' |
||||||
|
- question: What is the difference between Node.js and JavaScript? |
||||||
|
answer: Node.js is a runtime environment for JavaScript. JavaScript is a programming language used to create web applications. Node.js is a runtime environment that can execute JavaScript code outside of a web browser. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Beginner' |
||||||
|
- question: What is Event Loop in Node.js? |
||||||
|
answer: | |
||||||
|
The event loop is a single-threaded loop responsible for handling all asynchronous callbacks in Node.js. It continuously checks for events and executes associated callback functions, allowing Node.js to handle asynchronous tasks efficiently. Its non-blocking I/O model ensures that it can process multiple operations simultaneously without waiting for one to complete before moving on to the next, contributing to its scalability and performance. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Intermediate' |
||||||
|
- question: What is the difference between Node.js and AJAX? |
||||||
|
answer: | |
||||||
|
Node.js is a server-side runtime for JavaScript, while AJAX is a client-side technique for asynchronous communication with the server. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Beginner' |
||||||
|
- question: What are modules in Node.js? |
||||||
|
answer: | |
||||||
|
Modules are reusable blocks of code that can be imported into other files. They are used to encapsulate related code into a single unit of code that can be used in other parts of the program. It allow us to split our code into multiple files and reuse it across multiple files. Some built-in modules include `fs`, `http`, `path`, `url`, `util`, etc. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Beginner' |
||||||
|
- question: Difference between CommonJS and ESM? |
||||||
|
answer: commonjs-vs-esm.md |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Intermediate' |
||||||
|
- question: What is the `global` object in Node.js? |
||||||
|
answer: | |
||||||
|
The `global` object is a global namespace object that contains all global variables, functions, and objects. It is similar to the `window` object in the browser. It can be accessed from anywhere in the program without importing it. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Intermediate' |
||||||
|
- question: What is the difference between `process.nextTick()` and `setImmediate()`? |
||||||
|
answer: | |
||||||
|
`process.nextTick()` and `setImmediate()` are both used to schedule a callback function to be executed in the next iteration of the event loop. The difference is that `process.nextTick()` executes the callback at the end of the current iteration of the event loop, while `setImmediate()` executes the callback at the beginning of the next iteration of the event loop. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Intermediate' |
||||||
|
- question: What is `npm`? |
||||||
|
answer: | |
||||||
|
`npm` is a package manager for Node.js. It is used to install, update, and remove packages from the Node.js ecosystem. It is also used to manage dependencies for Node.js projects. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Beginner' |
||||||
|
- question: What are Event Emitters in Node.js? |
||||||
|
answer: | |
||||||
|
Event Emitters is a class that can be used to emit named events and register listeners for those events. It is used to handle asynchronous events in Node.js. It is similar to the `EventTarget` interface in the browser. |
||||||
|
topics: |
||||||
|
- 'Core' |
||||||
|
- 'Intermediate' |
||||||
|
--- |
Loading…
Reference in new issue