Test your understanding of Node.js fundamentals with this quiz covering key topics such as event-driven architecture, package management, async programming, and core modules. Ideal for interview preparation and Node.js beginners.
Node.js Overview
What is Node.js?
- A JavaScript runtime environment for executing code outside the browser
- A type of database engine
- An IDE for JavaScript
- A CSS preprocessor tool
Event-Driven Architecture
What does it mean when Node.js is described as 'event-driven'?
- It uses an event loop to manage asynchronous operations
- It executes code in random order
- It processes only synchronous code
- It handles tasks sequentially in a linear order
V8 Engine Role
Which of the following best describes the role of the V8 engine in Node.js?
- It compiles JavaScript code to machine code for fast execution
- It manages server hardware resources
- It provides a user interface for Node.js applications
- It handles network communication
Non-Blocking I/O
What is non-blocking I/O in Node.js useful for?
- Securing user passwords
- Slowing down server response times
- Allowing simultaneous handling of multiple requests
- Improving database storage capacity
Node.js Modules
Which is NOT a type of module in Node.js?
- External module
- Core module
- Local module
- Third-party module
npm Usage
What is the primary purpose of npm in a Node.js project?
- Encrypting server data
- Running database queries
- Creating HTML templates
- Managing and installing packages
package.json Purpose
What information is typically found in a project's package.json file?
- HTML layouts and CSS styles
- Server CPU usage statistics
- Database credentials and user passwords
- Project metadata, dependencies, and scripts
Asynchronous Programming Methods
Which of these is NOT a common method to handle asynchronous code in Node.js?
- Promises
- Async/await
- Callbacks
- Switch-case
Callback Function
What is a callback function in Node.js?
- A utility to compress files
- A function that is executed after an asynchronous task completes
- A property found only in JSON files
- A function that processes only HTTP requests
Difference Between npm and yarn
What is the main difference between npm and yarn?
- Both are package managers, but yarn focuses on speed and reliability
- npm is for back-end and yarn is for front-end only
- npm requires internet but yarn does not
- yarn only supports Python projects