📌 Node.
js Intern (Fresher) Interview
Questions & Answers
1. Basic JavaScript & [Link]
Q1. What is [Link] and why is it used?
A:
[Link] is a runtime environment that allows JavaScript to run outside the browser.
It is used for building fast, scalable, and event-driven backend applications because of its
non-blocking I/O and single-threaded architecture.
Q2. What is the difference between [Link] and JavaScript?
A:
● JavaScript: A programming language that runs in the browser.
● [Link]: A runtime that allows JavaScript to run on the server side, enabling backend
development.
Q3. What is npm?
A:
● npm stands for Node Package Manager.
● It is used to install, manage, and share libraries/packages in [Link] projects.
● Example: npm install express
2. REST APIs & Backend
Q4. What is a REST API?
A:
REST (Representational State Transfer) API is a way to structure communication between
client and server using HTTP methods like:
● GET → Retrieve data
● POST → Send data
● PUT → Update data
● DELETE → Remove data
Q5. Can you explain how you would create a simple API in [Link]?
A:
Yes, using [Link]:
const express = require('express');
const app = express();
const PORT = 3000;
[Link]('/', (req, res) => {
[Link]('Hello, World!');
});
[Link](PORT, () => {
[Link](`Server running on [Link]
});
3. Databases (MongoDB/MySQL Basics)
Q6. What is the difference between MongoDB and MySQL?
A:
● MongoDB → NoSQL database, stores data in JSON-like documents, flexible schema.
● MySQL → Relational database, stores data in tables with rows & columns, fixed
schema.
Q7. How do you connect [Link] to MongoDB?
A: Using mongoose library:
const mongoose = require('mongoose');
[Link]('mongodb://localhost:27017/mydb', { useNewUrlParser: true })
.then(() => [Link]('Connected to MongoDB'))
.catch(err => [Link](err));
4. Git & Version Control
Q8. What is Git and why do developers use it?
A:
Git is a version control system used to track changes in code, collaborate with teams, and
manage different versions of a project.
● git init → Initialize repository
● git add . → Stage changes
● git commit -m "message" → Save changes
● git push → Upload to GitHub
5. Coding/Problem Solving
Q9. Write a function in JavaScript to reverse a string.
A:
function reverseString(str) {
return [Link]('').reverse().join('');
}
[Link](reverseString("hello")); // "olleh"
Q10. How would you handle errors in [Link]?
A:
● Using try...catch blocks.
● Handling errors in callbacks.
● Using next(err) in Express middleware.
Example:
[Link]('/', (req, res, next) => {
try {
throw new Error("Something went wrong");
} catch (err) {
next(err); // pass error to error handler
}
});
6. HR / Internship Fit
Q11. Why do you want to work as a [Link] Intern?
A:
"I want to strengthen my backend development skills and gain hands-on experience in building
scalable APIs. Working as a [Link] Intern will help me learn from senior developers and apply
my knowledge in real-world projects."
Q12. How do you handle challenges when you don’t know something?
A:
● First, I try to research (official docs, StackOverflow, tutorials).
● If stuck, I ask my team members or mentors.
● I note down the solution so I don’t repeat the mistake.
📌 50 [Link] Intern Interview Questions
& Answers
1. JavaScript Basics
Q1. What are the different data types in JavaScript?
JavaScript has primitive types (string, number, boolean, null, undefined, symbol, bigint) and
non-primitive types (objects, arrays, functions).
Q2. What is the difference between == and === in JavaScript?
== checks for value equality with type conversion, while === checks for both value and type
equality without conversion.
Q3. What is the difference between var, let, and const?
● var is function-scoped and hoisted.
● let and const are block-scoped. const cannot be reassigned.
Q4. What are arrow functions in JavaScript?
Arrow functions provide a shorter syntax for functions and do not have their own this binding,
making them useful in callbacks.
Q5. What is a callback function?
A callback is a function passed as an argument to another function and executed later, often
used in asynchronous programming.
Q6. What are promises in JavaScript?
A promise represents a value that will be available in the future (resolved or rejected), making
asynchronous code easier to manage.
Q7. What is async/await in JavaScript?
async/await is syntactic sugar over promises, allowing asynchronous code to be written in a
synchronous style for better readability.
Q8. What is hoisting in JavaScript?
Hoisting is JavaScript’s behavior of moving declarations (variables and functions) to the top of
their scope before execution.
Q9. What is the difference between null and undefined?
undefined means a variable has been declared but not assigned, while null is an intentional
absence of value.
Q10. What is event bubbling in JavaScript?
Event bubbling is when an event propagates from the target element up through its parent
elements in the DOM tree.
2. [Link] Concepts
Q11. What is [Link] single-threaded model?
[Link] runs on a single thread using an event loop, allowing it to handle multiple requests
concurrently without creating new threads.
Q12. What is the event loop in [Link]?
The event loop continuously checks the call stack and callback queue, handling asynchronous
tasks efficiently.
Q13. What is the difference between blocking and non-blocking code?
Blocking code stops execution until the operation completes, while non-blocking code allows
other operations to run while waiting.
Q14. What is middleware in [Link]?
Middleware is a function that processes requests before they reach the final route handler,
often used for authentication, logging, and validation.
Q15. What are streams in [Link]?
Streams are objects that allow reading or writing data continuously, useful for handling large
files without loading them entirely into memory.
Q16. What is the difference between require() and import?
require() is used in CommonJS modules, while import is used in ES6 modules; both are
ways to include external files or packages.
Q17. How does [Link] handle multiple requests at once?
[Link] uses its event loop and asynchronous callbacks to handle multiple requests
concurrently on a single thread.
Q18. What is [Link] and why is it used?
[Link] is a lightweight [Link] framework for building web applications and APIs quickly
with features like routing and middleware.
Q19. How do you handle file uploads in [Link]?
We use middleware like multer to parse incoming file data and store files on the server or
cloud storage.
Q20. What are environment variables in [Link]?
Environment variables store configuration data (like database URLs, API keys) outside the
code, usually accessed via [Link].
3. REST APIs & Databases
Q21. What is CRUD in APIs?
CRUD stands for Create, Read, Update, Delete — the four basic operations performed on data
in a database or API.
Q22. How do you secure an API in [Link]?
By using authentication (JWT, OAuth), input validation, HTTPS, rate limiting, and sanitizing user
inputs against injections.
Q23. What is CORS in APIs?
CORS (Cross-Origin Resource Sharing) allows browsers to request resources from a different
domain, controlled by headers on the server.
Q24. What is the difference between SQL and NoSQL databases?
SQL databases use structured schemas with tables and rows, while NoSQL databases store
unstructured data like documents, key-value pairs, or graphs.
Q25. How do you query data in MongoDB?
We use Mongoose methods like find(), findOne(), or findById() to fetch data based on
conditions.
Q26. What is indexing in databases?
Indexing speeds up data retrieval by creating a quick lookup table, though it may slow down
write operations.
Q27. What is a schema in MongoDB (with Mongoose)?
A schema defines the structure of documents in a MongoDB collection, including fields, data
types, and validation rules.
Q28. How do you connect [Link] with MySQL?
By using the mysql2 or sequelize package, providing host, user, password, and database
credentials in connection setup.
Q29. What is the difference between save() and update() in MongoDB?
save() inserts or updates a whole document, while update() modifies only specific fields of
an existing document.
Q30. What is aggregation in MongoDB?
Aggregation is used for data processing and analysis, allowing grouping, filtering, and
transforming data using the aggregate() function.
4. Git & Tools
Q31. What is the difference between Git and GitHub?
Git is a version control system, while GitHub is a cloud-based hosting service for Git
repositories that enables collaboration.
Q32. What is a pull request in GitHub?
A pull request is a way to propose changes from one branch to another, usually reviewed by
teammates before merging.
Q33. What is the difference between git merge and git rebase?
git merge combines branches by adding a new commit, while git rebase rewrites commit
history to create a cleaner timeline.
Q34. What is .gitignore used for?
It specifies files and folders that Git should ignore, such as environment files, logs, or
node_modules.
Q35. What is the difference between git fetch and git pull?
git fetch only downloads changes from the remote, while git pull downloads and
merges them into the current branch.
5. Coding/Problem Solving
Q36. Write a function to check if a number is even or odd in JavaScript.
function isEven(num) {
return num % 2 === 0 ? "Even" : "Odd";
}
Q37. Write a function to find the factorial of a number.
function factorial(n) {
if (n === 0) return 1;
return n * factorial(n - 1);
}
Q38. Write a function to find the largest number in an array.
function largest(arr) {
return [Link](...arr);
}
Q39. Write a function to check if a string is a palindrome.
function isPalindrome(str) {
return str === [Link]('').reverse().join('');
}
Q40. How do you read a JSON file in [Link]?
We can use [Link]('[Link]') and then parse it using [Link]().
6. HR / Internship Fit
Q41. Tell me about yourself.
I am a fresher with skills in JavaScript, [Link], and databases. I am eager to apply my
knowledge in real projects and grow as a backend developer.
Q42. Why should we hire you as a [Link] Intern?
I have a strong foundation in JavaScript and [Link], quick learning ability, and enthusiasm to
contribute to backend development.
Q43. What are your strengths?
My strengths are problem-solving, quick learning, and teamwork. I am also detail-oriented and
dedicated to writing clean code.
Q44. What are your weaknesses?
Sometimes I spend extra time perfecting code, but I am learning to balance efficiency with
quality.
Q45. Where do you see yourself in 3 years?
I see myself as a skilled backend developer, contributing to scalable applications and possibly
leading small teams.
Q46. How do you handle tight deadlines?
I prioritize tasks, break them into smaller steps, and stay focused while communicating
progress with my team.
Q47. How do you handle conflicts in a team?
I listen to both sides, discuss calmly, and try to find a solution that benefits the project and
maintains team harmony.
Q48. What do you expect from this internship?
I expect hands-on experience in [Link] projects, mentorship from senior developers, and
opportunities to improve my coding skills.
Q49. How do you stay updated with new technologies?
I follow developer blogs, official documentation, YouTube tutorials, and practice on GitHub
projects.
Q50. Do you prefer frontend or backend development, and why?
I prefer backend development because I enjoy working with data, APIs, and server logic, which
feels more problem-solving oriented.
📌 [Link] Intern Coding Questions
(Fresher Level)
1. Hello World API
👉 Write an [Link] API that returns "Hello, World!" when a GET request is made to /.
Answer (Code):
const express = require('express');
const app = express();
const PORT = 3000;
[Link]('/', (req, res) => {
[Link]('Hello, World!');
});
[Link](PORT, () => [Link](`Server running on port ${PORT}`));
2. Create a Simple CRUD API (Users)
👉 Build an API with the following routes:
● POST /users → Add user
● GET /users → Get all users
● PUT /users/:id → Update user
● DELETE /users/:id → Delete user
Answer (Code - using in-memory array):
const express = require('express');
const app = express();
[Link]([Link]());
let users = []; // temporary storage
// Create
[Link]('/users', (req, res) => {
[Link]([Link]);
[Link]({ message: "User added", users });
});
// Read
[Link]('/users', (req, res) => {
[Link](users);
});
// Update
[Link]('/users/:id', (req, res) => {
const id = [Link];
users[id] = [Link];
[Link]({ message: "User updated", users });
});
// Delete
[Link]('/users/:id', (req, res) => {
const id = [Link];
[Link](id, 1);
[Link]({ message: "User deleted", users });
});
[Link](3000, () => [Link]("Server running on port 3000"));
3. Connect [Link] with MongoDB
👉 Write code to connect [Link] to a local MongoDB database.
const mongoose = require('mongoose');
[Link]('mongodb://localhost:27017/internDB', { useNewUrlParser: true,
useUnifiedTopology: true })
.then(() => [Link]("MongoDB Connected"))
.catch(err => [Link](err));
4. Create User Schema in MongoDB
👉 Define a User schema with name, email, and age fields using Mongoose.
const mongoose = require('mongoose');
const userSchema = new [Link]({
name: String,
email: String,
age: Number
});
const User = [Link]("User", userSchema);
[Link] = User;
5. Build Login API with Express
👉 Write a login API that checks if username and password are correct.
const express = require('express');
const app = express();
[Link]([Link]());
const USERS = [{ username: "admin", password: "1234" }];
[Link]('/login', (req, res) => {
const { username, password } = [Link];
const user = [Link](u => [Link] === username && [Link] === password);
if (user) [Link]({ message: "Login successful" });
else [Link](401).json({ message: "Invalid credentials" });
});
[Link](3000, () => [Link]("Server running on port 3000"));
6. Read JSON File in [Link]
👉 Write code to read [Link] and return it as a response.
const fs = require('fs');
const express = require('express');
const app = express();
[Link]('/data', (req, res) => {
const data = [Link]('[Link]');
[Link]([Link](data));
});
[Link](3000, () => [Link]("Server running on port 3000"));
7. Build API with Query Parameters
👉 Create an API /greet?name=Ashish → returns "Hello Ashish".
[Link]('/greet', (req, res) => {
const name = [Link] || "Guest";
[Link](`Hello ${name}`);
});
8. Write Middleware for Logging Requests
👉 Create a middleware that logs request method and URL.
const logger = (req, res, next) => {
[Link](`${[Link]} ${[Link]}`);
next();
};
[Link](logger);
9. Upload File with Multer
👉 Write an API to upload a file.
const multer = require('multer');
const upload = multer({ dest: 'uploads/' });
[Link]('/upload', [Link]('file'), (req, res) => {
[Link]({ message: "File uploaded", file: [Link] });
});
10. Build API with Route Parameters
👉 Create an API /user/:id that returns "User ID is <id>".
[Link]('/user/:id', (req, res) => {
[Link](`User ID is ${[Link]}`);
});
📌 JavaScript Interview Questions &
Answers (with Code)
1. What are the different data types in JavaScript?
JavaScript has primitive types (string, number, boolean, null, undefined, symbol, bigint) and
non-primitive types (object, array, function).
let name = "Ashish"; // string
let age = 22; // number
let isIntern = true; // boolean
let value = null; // null
let data; // undefined
let user = { id: 1 }; // object
2. What is the difference between == and ===?
● == → compares values after type conversion.
● === → compares values and types (strict equality).
[Link](5 == "5"); // true
[Link](5 === "5"); // false
3. What is hoisting in JavaScript?
Hoisting moves declarations (not initializations) to the top of the scope.
[Link](a); // undefined
var a = 10; // variable is hoisted but not its value
4. What are arrow functions?
Arrow functions provide a shorter syntax and don’t have their own this.
const add = (a, b) => a + b;
[Link](add(3, 4)); // 7
5. What is the difference between var, let, and const?
● var → function-scoped, can be redeclared.
● let → block-scoped, can be reassigned.
● const → block-scoped, cannot be reassigned.
var x = 1;
let y = 2;
const z = 3;
6. What is a closure?
A closure is a function that remembers its outer scope even after execution.
function outer() {
let count = 0;
return function inner() {
count++;
return count;
};
}
const counter = outer();
[Link](counter()); // 1
[Link](counter()); // 2
7. What are promises in JavaScript?
Promises represent future values for async operations.
const promise = new Promise((resolve, reject) => {
setTimeout(() => resolve("Done!"), 1000);
});
[Link](result => [Link](result)); // Done!
8. What is async/await?
async/await is syntactic sugar for promises, making async code easier to read.
async function fetchData() {
let data = await [Link]("Hello");
[Link](data);
}
fetchData(); // Hello
9. Explain event bubbling and capturing.
● Bubbling → Event goes from child → parent.
● Capturing → Event goes from parent → child.
[Link]("btn").addEventListener("click", () => {
[Link]("Button clicked");
});
10. How do you copy an object in JavaScript?
We can use spread operator or [Link]().
let user = { name: "Ashish" };
let copy1 = { ...user };
let copy2 = [Link]({}, user);
11. How to reverse a string in JavaScript?
function reverse(str) {
return [Link]("").reverse().join("");
}
[Link](reverse("hello")); // olleh
12. How to find the largest number in an array?
let arr = [3, 9, 2, 7];
[Link]([Link](...arr)); // 9
13. How to check if a number is prime?
function isPrime(n) {
if (n <= 1) return false;
for (let i = 2; i < n; i++) {
if (n % i === 0) return false;
}
return true;
}
[Link](isPrime(7)); // true
14. How to check if a string is a palindrome?
function isPalindrome(str) {
return str === [Link]("").reverse().join("");
}
[Link](isPalindrome("madam")); // true
15. How to remove duplicates from an array?
let arr = [1, 2, 2, 3, 4, 4];
let unique = [...new Set(arr)];
[Link](unique); // [1, 2, 3, 4]
16. What is the difference between map(), filter(), and
forEach()?
● map() → transforms array elements.
● filter() → selects specific elements.
● forEach() → executes function for each element.
let nums = [1, 2, 3, 4];
[Link]([Link](n => n * 2)); // [2, 4, 6, 8]
[Link]([Link](n => n % 2)); // [1, 3]
[Link](n => [Link](n)); // prints 1,2,3,4
17. How to flatten an array in JavaScript?
let arr = [1, [2, [3, 4]]];
[Link]([Link](2)); // [1, 2, 3, 4]
18. How to sort numbers in ascending order?
let nums = [10, 5, 8, 1];
[Link]((a, b) => a - b);
[Link](nums); // [1, 5, 8, 10]
19. What is the difference between null and undefined?
● null → intentional absence of value.
● undefined → variable declared but not assigned.
let a; // undefined
let b = null; // null
20. What is the difference between call(), apply(), and
bind()?
● call() → calls function with arguments individually.
● apply() → calls function with arguments as array.
● bind() → returns a new function with this bound.
function greet(msg) {
[Link](`${msg}, ${[Link]}`);
}
const user = { name: "Ashish" };
[Link](user, "Hello"); // Hello, Ashish
[Link](user, ["Hi"]); // Hi, Ashish
const bound = [Link](user, "Hey");
bound(); // Hey, Ashish