JavaScript Interview Questions for Freshers (2026)

What JavaScript questions are asked to freshers? Interviewers usually ask var vs let vs const, hoisting, == vs ===, closures, the this keyword, arrow functions, array methods (map, filter, reduce), promises and async/await, the event loop and DOM basics. Then they give a few output puzzles and a small coding task. If you can explain each idea in one or two lines and show a tiny code example, you cover most first-round JavaScript interviews.
This guide from VibrantMinds Technologies in Pune gives 50+ JavaScript interview questions and answers, with code, output puzzles, coding tasks, trap questions and a 14-day plan. It is written for anyone searching JavaScript interview questions for freshers, JavaScript interview questions and answers, JavaScript output questions for interview, var vs let vs const interview question, JavaScript closures interview questions, JavaScript promises and async await interview questions, difference between == and === in JavaScript, JavaScript event loop explained for beginners, JavaScript coding questions for freshers or a free IT job WhatsApp group for full stack freshers in Pune.
Takeaway | Detail |
|---|---|
Explain, then show code | One-line definition plus a 3 to 5 line example. |
Four ideas decide most rounds | Scope and hoisting, closures, |
Use |
|
Know the event loop order | Synchronous code, then microtasks (promises), then macrotasks ( |
Prefer | Block scope avoids a whole class of bugs. |
Practise output puzzles | They test understanding, not memory. |
Be honest | “I’m not sure, but I’d check the documentation” is better than guessing. |
HOW A JAVASCRIPT INTERVIEW USUALLY FLOWS
MODULE 1: BASICS AND DATA TYPES (Q1 TO Q10)
Q1. What is JavaScript?
Answer: A high-level, dynamically typed, interpreted language that runs in browsers and, through Node.js, on servers. It’s used to make web pages interactive and to build full stack applications.
Q2. What are the data types in JavaScript?
Answer: Primitives: string, number, bigint, boolean, undefined, null, symbol. Non-primitive: objects (including arrays and functions).
Q3. null vs undefined
Point |
|
|
|---|---|---|
Meaning | A variable declared but not assigned | An intentional “no value” |
Who sets it | JavaScript | The programmer |
|
|
|
Q4. == vs ===
Answer: == compares after type conversion, === compares value and type with no conversion.
javascript
Best practice: use === unless you have a specific reason.
Q5. What is type coercion?
Answer: Automatic conversion of one type to another, for example "3" - 1 gives 2, while 1 + "2" gives "12".
Q6. What is NaN? How do you check for it?
Answer: “Not a Number”, the result of invalid numeric operations. NaN === NaN is false, so use Number.isNaN(value).
Q7. What are truthy and falsy values?
Answer: Falsy values: false, 0, "", null, undefined, NaN (and 0n). Everything else is truthy, including "0", [] and {}.
Q8. What does typeof return for common values?
Expression | Result |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Use Array.isArray(x) to check for arrays.
Q9. What is the difference between primitives and objects in assignment?
Answer: Primitives are copied by value. Objects and arrays are copied by reference, so two variables can point to the same object.
javascript
Q10. Why does 0.1 + 0.2 === 0.3 return false?
Answer: Numbers use binary floating-point, so some decimals can’t be represented exactly. Compare with a small tolerance or use rounding for money-like values.
MODULE 2: VARIABLES, SCOPE AND HOISTING (Q11 TO Q18)
Q11. var vs let vs const
Point |
|
|
|
|---|---|---|---|
Scope | Function | Block | Block |
Re-declare | Allowed | Not allowed in the same scope | Not allowed |
Re-assign | Allowed | Allowed | Not allowed |
Hoisting | Hoisted, initialised as | Hoisted, but in the temporal dead zone | Same as |
Recommendation | Avoid | Use when the value changes | Use by default |
Q12. Does const make an object immutable?
Answer: No. const prevents re-assigning the variable, but the object’s contents can still change. Use Object.freeze() for shallow immutability.
javascript
Q13. What is hoisting?
Answer: JavaScript moves declarations to the top of their scope during the creation phase. Function declarations are fully hoisted. var is hoisted and set to undefined. let and const are hoisted but can’t be used before their declaration.
javascript
Q14. What is the temporal dead zone (TDZ)?
Answer: The period between entering a scope and the line where a let or const variable is declared. Accessing it throws a ReferenceError.
Q15. What is scope? Types?
Answer: The area where a variable is accessible: global, function and block scope.
Q16. What is the scope chain?
Answer: When a variable isn’t found in the current scope, JavaScript looks in the outer scope, then the next, up to the global scope.
Q17. Function declaration vs function expression
javascript
Q18. What is an IIFE?
Answer: An Immediately Invoked Function Expression, a function that runs as soon as it is defined, often used to create a private scope.
javascript
MODULE 3: FUNCTIONS, CLOSURES AND this (Q19 TO Q28)
Q19. What is a closure?
Answer: A closure is a function that remembers the variables from the scope where it was created, even after that outer function has finished.
javascript
count stays alive because the inner function still references it. It is also private: nothing outside can change it directly.
Q20. Where are closures used in real code?
Answer: Data privacy, counters, memoization, event handlers, callbacks and function factories.
Q21. The classic closure-in-a-loop question
javascript
Why: var has one function-scoped i, so by the time the callbacks run it equals 3. let creates a new binding for each iteration.
Q22. What is a callback?
Answer: A function passed as an argument to be called later.
Q23. What are higher-order functions?
Answer: Functions that take other functions as arguments or return functions, such as map, filter, reduce and forEach.
Q24. What is the this keyword?
Answer: A reference to the object that is executing the current function. Its value depends on how the function is called.
Situation |
|
|---|---|
Method call |
|
Plain function call (non-strict) | The global object ( |
Plain function call (strict mode) |
|
Arrow function |
|
| The new object |
| The object you pass in |
Q25. Arrow function vs regular function
Point | Regular function | Arrow function |
|---|---|---|
| Depends on the call | Inherits from the outer scope |
| Yes | No |
Can be a constructor ( | Yes | No |
Syntax | Longer | Shorter |
javascript
Q26. call, apply and bind
javascript
Difference: call takes arguments one by one, apply takes an array and bind returns a new function without calling it.
Q27. What are default and rest parameters?
javascript
Q28. What is a pure function?
Answer: A function that returns the same output for the same input and has no side effects, which makes it easy to test.
MODULE 4: ARRAYS, OBJECTS AND ES6 (Q29 TO Q38)
Q29. map, filter and reduce
javascript
Q30. forEach vs map
Answer: forEach runs a function for each item and returns undefined. map returns a new array of transformed values.
Q31. What are find, some and every?
javascript
Q32. What is destructuring?
javascript
Q33. Spread vs rest
javascript
Q34. Shallow copy vs deep copy
Answer: A shallow copy (spread, Object.assign) copies only the top level, so nested objects are still shared. A deep copy duplicates everything. Use structuredClone(obj) in modern environments.
Q35. What are template literals?
javascript
Q36. What are Set and Map?
Answer: Set stores unique values. Map stores key-value pairs where keys can be any type.
javascript
Q37. What is optional chaining (?.) and nullish coalescing (??)?
javascript
?? differs from || because || also replaces 0 and "".
Q38. What are ES modules?
Answer: The standard way to split code using export and import.
javascript
MODULE 5: ASYNCHRONOUS JAVASCRIPT (Q39 TO Q48)
Q39. Why is JavaScript called single-threaded?
Answer: It has one call stack and runs one piece of code at a time. Asynchronous work (timers, network calls) is handled by the browser or Node.js and its results come back through queues.
Q40. How does the event loop work?
Order: run all synchronous code, then all queued microtasks (promise callbacks), then one macrotask (such as a setTimeout callback), then repeat.
Q41. What is the output?
javascript
Q42. What is a callback hell? How do you avoid it?
Answer: Deeply nested callbacks that are hard to read. Avoid it with promises or async/await and by splitting code into small functions.
Q43. What is a Promise?
Answer: An object representing the eventual result of an asynchronous operation. It has three states: pending, fulfilled and rejected.
javascript
Q44. async/await
javascript
Key points: async functions always return a promise, await pauses the function (not the whole program) until the promise settles and errors are handled with try/catch.
Q45. Promise.all, allSettled, race and any
Method | Behaviour |
|---|---|
| Resolves when all succeed, rejects if any fails |
| Waits for all and reports each result, never rejects |
| Settles with the first promise to settle |
| Resolves with the first success, rejects if all fail |
Q46. Sequential vs parallel awaits
javascript
Q47. What does fetch return, and does it reject on a 404?
Answer: fetch returns a promise for a Response. It rejects only on network failures. For HTTP errors such as 404 or 500 it still resolves, so check res.ok or res.status.
Q48. What are setTimeout and setInterval?
Answer: setTimeout runs a function once after a delay. setInterval runs it repeatedly. Clear them with clearTimeout and clearInterval. A delay of 0 still runs after the current synchronous code.
MODULE 6: DOM AND BROWSER BASICS (Q49 TO Q54)
Q49. What is the DOM?
Answer: The Document Object Model, a tree representation of a web page that JavaScript can read and change.
Q50. How do you select and change elements?
javascript
Q51. What is event bubbling and event delegation?
Answer: Bubbling: an event on a child element travels up through its parents. Delegation: attach one listener to a parent and handle child events using event.target, which is efficient for dynamic lists.
javascript
Q52. localStorage vs sessionStorage vs cookies
Storage | Lifetime | Sent to server automatically |
|---|---|---|
| Until cleared | No |
| Until the tab closes | No |
Cookies | Until expiry | Yes, with requests |
Never store passwords or sensitive tokens carelessly in browser storage.
Q53. What is JSON and how do you use it?
javascript
Q54. innerHTML vs textContent
Answer: innerHTML parses HTML and can introduce XSS risk if it contains user input. textContent inserts plain text and is safer.
OUTPUT PUZZLES (PREDICT BEFORE YOU RUN)
Puzzle 1
javascript
Output: object, then undefined.
Puzzle 2
javascript
Output: 12, 2, 2.
Puzzle 3
javascript
Output: false, true. ([] converts to an empty string, then to 0, so it equals false with ==.)
Puzzle 4
javascript
Output: undefined. The local var x is hoisted inside test, so the outer x is hidden.
Puzzle 5
javascript
Output: false, false, true. (includes uses a comparison that treats NaN as equal to NaN.)
Puzzle 6
javascript
Output: 5. Both variables reference the same object.
CODING ROUND: 8 TASKS WITH SOLUTIONS
1. Reverse a string
javascript
2. Check a palindrome
javascript
3. Remove duplicates from an array
javascript
4. Count character frequency
javascript
5. Find the largest number
javascript
6. FizzBuzz
javascript
7. Flatten a nested array
javascript
8. Write a simple debounce
javascript
It’s a closure in action, because timer is remembered between calls.
TRAP QUESTIONS INTERVIEWERS ASK
Trap | Correct thinking |
|---|---|
“Is JavaScript the same as Java?” | No. They are different languages with different designs. |
“Does | No, only the binding is constant. |
“Is | It returns |
“Is | No, it runs after the current code and pending microtasks. |
“Does | It does not wait for async callbacks. Use |
“Does | No, check |
“Is | It becomes an empty string. |
“Are arrow functions just shorter syntax?” | They also change how |
COMMON MISTAKES FRESHERS MAKE IN JAVASCRIPT INTERVIEWS
Mistake | Why it hurts | Better approach |
|---|---|---|
Memorising definitions only | Output puzzles expose gaps | Run every example yourself |
Using | Surprising conversions | Use |
Confusing hoisting for | Common question | Remember TDZ vs |
Not knowing the event loop | A favourite round-two topic | Learn the microtask-then-macrotask order |
Forgetting error handling in async code | Looks careless | Use |
Mutating arrays and objects accidentally | Hidden bugs | Learn spread, |
Not explaining while coding | Interviewer can’t follow | Narrate your logic |
Calling everything “fast” or “slow” without reasons | Weak answers | Mention complexity and trade-offs |
14-DAY JAVASCRIPT PREPARATION PLAN
Day | Focus | Task |
|---|---|---|
1 | Data types and coercion | Q1 to Q10, |
2 |
| Q11 to Q14, write hoisting examples |
3 | Scope and functions | Q15 to Q18, declarations vs expressions |
4 | Closures | Q19 to Q21, build a counter and the loop example |
5 |
| Q24 to Q26, practise |
6 | Arrays | Q29 to Q31, practise |
7 | ES6 features | Q32 to Q38, destructuring, spread, optional chaining |
8 | Event loop | Q39 to Q41, predict outputs of 5 sequences |
9 | Promises | Q43 and Q45, write your own promise |
10 | async/await and | Q44, Q46 to Q47, call a public API with error handling |
11 | DOM and events | Q49 to Q54, build a small to-do page |
12 | Output puzzles | Solve all six, then write two of your own |
13 | Coding tasks | Solve the 8 tasks without looking |
14 | Mock interview | Answer Q1 to Q54 aloud and explain your best project |
MYTH VS REALITY
Myth | Reality |
|---|---|
“JavaScript is easy, so interviews are easy.” | Interviewers test scope, closures and async behaviour deeply. |
“Frameworks mean I don’t need core JavaScript.” | React and others are built on these fundamentals. |
“ | Scope and hoisting differ. |
“ | It looks synchronous but remains asynchronous. |
“Output puzzles are tricks.” | They test whether you understand how the language works. |
“Java and JavaScript are related.” | Same word, different languages. |
HOW VIBRANTMINDS HELPS FRESHERS BUILD FULL STACK SKILLS
VibrantMinds Technologies Pvt. Ltd. is a Pune-based IT training and placement support company. If you searched for VibrantMinds or VibrantMinds Technologies, here is what it offers:
Full Stack Java Development (about 4 to 6 months): Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, HTML, CSS, JavaScript and front-end basics, projects, aptitude and interview preparation. Please check the candidate portal for the latest syllabus and tools.
Software Testing (Manual + Automation), Core Java and Python & Data Science for other career paths
Project practice: Build full stack projects you can host on GitHub and explain confidently
Interview preparation: Technical rounds, coding practice, project rounds, HR rounds, aptitude, communication and mock interviews
Placement support: Screening, drive coordination and interview support. Check https://candidates.vibrantminds.in/ for current openings.
Free WhatsApp job alert groups for fresher IT jobs, campus drives and walk-in alerts
Honesty first: VibrantMinds offers placement support, not a guaranteed job, and no legitimate recruiter should ask you to pay to be interviewed.
VibrantMinds works as a talent ecosystem connecting candidates, colleges and companies, with 1900+ partner colleges and 600+ hiring companies. More fresher job guidance: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026
VIBRANTMINDS COURSES AT A GLANCE
Course | Duration | Key topics |
|---|---|---|
Full Stack Java Development | 4 to 6 months | Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation |
Software Testing (Manual + Automation) | 2 to 5 months | Test cases, STLC, bug tracking, SQL, Selenium basics |
Core Java | 1 to 2 months | Syntax, OOP, collections, exceptions, strings |
Python & Data Science | 2 to 4 months | Python basics, data handling, analysis fundamentals |
Fees, syllabus and batch dates are on https://candidates.vibrantminds.in/. Please confirm them directly before enrolling.
THE VIBRANTMINDS PLACEMENT PIPELINE: SIX STEPS
REAL OUTCOMES: WHAT TO EXPECT AND WHAT NOT TO
Past students have shared positive feedback about the training and support, and have gone on to roles at companies such as Aress Software and Education Technologies, Saama Technologies and Three M Software. Results vary by candidate, skill level, effort and market conditions, so please confirm details directly with the VibrantMinds team. No one can honestly promise a guaranteed job.
JOIN FREE VIBRANTMINDS WHATSAPP GROUPS: FREE IT JOB UPDATES FOR FULL STACK AND JAVA FRESHERS IN PUNE AND INDIA
Looking for free WhatsApp groups, free IT job WhatsApp groups, a Java WhatsApp group for freshers or a job updates WhatsApp group in India? The VibrantMinds groups share fresher IT openings, campus drives, walk-in interview alerts and interview preparation updates, free of charge. Join whichever group has space. All three carry the same type of updates.
Group | What it offers | Link |
|---|---|---|
VibrantMinds Fresher IT Jobs, Group 1 | Fresher openings, campus drives, walk-in alerts | |
VibrantMinds Fresher IT Jobs, Group 2 | Fresher openings, campus drives, walk-in alerts | |
VibrantMinds Fresher IT Jobs, Group 3 | Fresher openings, campus drives, walk-in alerts |
Never pay to apply. Legitimate recruiters do not charge candidates for tests, interviews or offer letters. Do not share sensitive personal or financial details in any group chat.
FREQUENTLY ASKED QUESTIONS
1. What are the most asked JavaScript interview questions for freshers?
The difference between var, let and const, hoisting, == vs ===, closures, the this keyword, arrow functions, map, filter and reduce, promises, async/await, the event loop, DOM basics and output puzzles. Many interviews also include a small coding task such as reversing a string or removing duplicates.
2. What is hoisting in JavaScript with an example?
Hoisting means declarations are processed before code runs. A var variable is hoisted and holds undefined until assigned, so console.log(a); var a = 5; prints undefined. let and const are hoisted too, but using them before their declaration throws a ReferenceError because of the temporal dead zone.
3. What is a closure in JavaScript with a simple example?
A closure is a function that remembers the variables from the scope where it was created, even after the outer function has finished. For example, a makeCounter() function that returns an inner function keeps its private count variable, and each call to the inner function increases it.
4. How does the JavaScript event loop work for beginners?
JavaScript runs synchronous code on the call stack first. When the stack is empty, the event loop runs all queued microtasks (promise callbacks), then one macrotask (such as a setTimeout callback), and repeats. That is why a promise callback runs before a setTimeout of 0.
5. Is there a free WhatsApp group for full stack freshers in Pune?
Yes. VibrantMinds runs free fresher IT job WhatsApp groups that share Java, full stack and other IT openings, campus drives and walk-in alerts. Join through the links above, and always verify a job post and never pay to apply.
CONCLUSION: UNDERSTAND THE ENGINE, NOT JUST THE SYNTAX
The best way to handle JavaScript interview questions for freshers is to understand how the language really works: scope and hoisting, closures, this, promises and the event loop. Run every example, predict the output puzzles before checking, practise the coding tasks, explain answers aloud and follow the 14-day plan. Honest, clear explanations beat memorised definitions.
If you’re in Pune and want structured Java full stack training with JavaScript, projects, interview preparation and placement support, VibrantMinds Technologies is here to help.
Call to action:
Website: https://vibrantminds.in/
Candidate portal and courses: https://candidates.vibrantminds.in/
Fresher jobs guide: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026
Join the free WhatsApp groups: the three links above
VISIT OR CONTACT VIBRANTMINDS IN PUNE
Company: VibrantMinds Technologies Pvt. Ltd.
Address: Viva Academy Building, Warje, Pune, Maharashtra 411052
Phone: +91 95035 79517
Email: support@vibrantmindstech.com
Website: https://vibrantminds.in/
Candidate portal and courses: https://candidates.vibrantminds.in/


