๐น JavaScript Basics (1โ15)
1. What is JavaScript?
JavaScript is a lightweight, interpreted programming language used to make web pages interactive (buttons, forms, animations, APIs, etc.).
2. Is JavaScript compiled or interpreted?
JavaScript is interpreted, but modern browsers use JIT (Just-In-Time) compilation for faster execution.
3. Difference between var, let, and const?
| Feature | var | let | const |
|---|---|---|---|
| Scope | Function | Block | Block |
| Redeclare | Yes | No | No |
| Reassign | Yes | Yes | No |
4. What is undefined?
A variable declared but not assigned a value is undefined.
5. What is null?
null means intentional empty value.
6. Difference between == and ===?
==โ compares value only===โ compares value + data type
7. What are JavaScript data types?
Primitive: String, Number, Boolean, Undefined, Null, Symbol, BigInt
Non-Primitive: Object, Array, Function
8. What is NaN?
NaN means Not a Number, returned when invalid math operations happen.
9. What is typeof operator?
Used to check data type.
typeof "Hello" // string
10. What is an array?
Array stores multiple values in one variable.
let arr = [1, 2, 3];
11. What is an object?
Object stores data in key-value pairs.
let user = { name: "Parvej", age: 22 };
12. What is function?
A reusable block of code.
function add(a, b) {
return a + b;
}
13. Arrow function?
Short syntax for function.
const add = (a, b) => a + b;
14. What is template literal?
Used for string interpolation.
`Hello ${name}`
15. What is default parameter?
function greet(name = "User") {}
๐น JavaScript Advanced Concepts (16โ35)
16. What is hoisting?
JavaScript moves variable & function declarations to the top of scope.
17. What is closure?
A function that remembers its outer scope.
18. What is scope?
Defines where variables are accessible.
- Global
- Local
- Block
19. What is callback function?
A function passed as an argument to another function.
20. What is promise?
Handles asynchronous operations.
promise.then().catch();
21. Promise states?
- Pending
- Fulfilled
- Rejected
22. What is async/await?
Simplifies promises.
async function fetchData() {
await fetch(url);
}
23. What is event loop?
Handles async tasks using call stack & callback queue.
24. What is DOM?
DOM = Document Object Model, represents HTML as objects.
25. What is BOM?
Browser Object Model (window, alert, location).
26. What is this keyword?
Refers to the current object.
27. What is map()?
Creates new array by modifying elements.
28. What is filter()?
Returns elements that match condition.
29. What is reduce()?
Reduces array to single value.
30. What is spread operator?
let arr2 = [...arr1];
31. What is rest parameter?
function sum(...nums) {}
32. What is destructuring?
Extract values from arrays/objects.
const { name } = user;
33. What is localStorage?
Stores data permanently in browser.
34. What is sessionStorage?
Stores data until tab is closed.
35. What is JSON?
JavaScript Object Notation โ data exchange format.
๐น JavaScript Practical / Interview Tricky (36โ50)
36. Difference between synchronous & asynchronous?
- Sync โ blocks execution
- Async โ non-blocking
37. What is setTimeout?
Executes code after delay.
38. What is setInterval?
Executes code repeatedly.
39. What is strict mode?
"use strict";
Prevents errors & unsafe code.
40. What is IIFE?
Immediately Invoked Function Expression.
(function() {})();
41. What is shallow copy?
Copies reference.
42. What is deep copy?
Copies actual data.
43. What is event bubbling?
Event moves child โ parent.
44. What is event capturing?
Event moves parent โ child.
45. What is debounce?
Limits function execution.
46. What is throttle?
Controls execution rate.
47. What is prototype?
Mechanism for inheritance.
48. What is bind()?
Creates new function with fixed this.
49. What is call()?
Calls function with this immediately.
50. What is apply()?
Same as call but arguments in array.