TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses · 55.7K subscribers
Post #3075 6.97K
✅ 20 JavaScript Interview Questions

1. What are the different data types in JavaScript
• String, Number, Boolean, Undefined, Null, Object, Symbol, BigInt
Use typeof to check a variable’s type.

2. What is the difference between == and ===
• == compares values with type coercion
• === compares both value and type (strict equality)

3. What is hoisting in JavaScript
Variables and function declarations are moved to the top of their scope before execution.
Only declarations are hoisted, not initializations.

4. What is a closure
A function that remembers variables from its outer scope even after the outer function has finished executing.
Example:
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1


5. What is the difference between var, let, and const
• var: function-scoped, can be re-declared
• let: block-scoped, can be updated
• const: block-scoped, cannot be re-assigned

6. What is event delegation
Using a single event listener on a parent element to handle events from its child elements using event.target.

7. What is the use of promises in JavaScript
Handle asynchronous operations.
States: pending, fulfilled, rejected
Example:
fetch(url)
.then(res => res.json())
.catch(err => console.error(err));


8. What is async/await
Syntactic sugar over promises for cleaner async code
Example:
async function getData() {
const res = await fetch(url);
const data = await res.json();
console.log(data);
}


9. What is the difference between null and undefined
• null: intentional absence of value
• undefined: variable declared but not assigned

10. What is the use of arrow functions
Shorter syntax, no own this binding
Example:
const add = (a, b) => a + b;


11. What is the DOM
Document Object Model — represents HTML as a tree structure. JavaScript can manipulate it using methods like getElementById, querySelector, etc.

12. What is the difference between call, apply, and bind
• call: invokes function with arguments passed individually
• apply: invokes function with arguments as array
• bind: returns a new function with bound context

13. What is the use of setTimeout and setInterval
• setTimeout: runs code once after delay
• setInterval: runs code repeatedly at intervals

14. What is the difference between stack and heap
• Stack: stores primitive values and function calls
• Heap: stores objects and reference types

15. What is the use of the spread operator (...)
Expands arrays/objects or merges them
Example:
const arr = [1, 2];
const newArr = [...arr, 3]; // [1, 2, 3]


16. What is the difference between map and forEach
• map: returns a new array
• forEach: performs action but returns undefined

17. What is the use of localStorage and sessionStorage
• localStorage: persists data even after browser is closed
• sessionStorage: persists data only for session

18. What is a prototype in JavaScript
Every object has a prototype — an object it inherits methods and properties from. Enables inheritance.

19. What is the difference between synchronous and asynchronous code
• Synchronous: executes line by line
• Asynchronous: executes independently, doesn’t block main thread

20. What are modules in JavaScript
Used to split code into reusable pieces
Example:
// file.js
export const greet = () => "Hello";

// main.js
import { greet} from './file.js';


👍 React for more Interview Resources #javascript #interview #coding #webdev #frontend
  • ❤ 13
  • 👍 6
More from @javascript_courses
  1. Oct 9, 2026🇮🇳 𝗚𝗢𝗩𝗘𝗥𝗡𝗠𝗘𝗡𝗧 𝗢𝗙 𝗜𝗡𝗗𝗜𝗔 — 𝗔𝗜𝗖𝗧𝗘 𝗜𝗡𝗧𝗘𝗥𝗡𝗦𝗛𝗜𝗣𝗦 𝟮𝟬𝟮𝟲 🚀…
  2. Oct 8, 2026🎓 𝗠𝗶𝗰𝗿𝗼𝘀𝗼𝗳𝘁 𝗙𝗥𝗘𝗘 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝘄𝗶𝘁𝗵 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗲𝘀! 🚀🔥 Upgr…
  3. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  4. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  5. Oct 4, 2026DSA Handwritten Notes
  6. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these st…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →