1.
map() Method in JavaScript
The map() method creates a new array by applying a function to each element.
It does not modify the original array.
const num = [1, 2, 3, 4, 5];
const doubled = [Link](n => n * 2);
[Link](doubled);
[Link](num);
2. Higher Order Function
A higher order function takes another function as an argument or returns a function.
const num2 = [1, 2, 3, 4, 5];
const squared = [Link](function (n) {
return n * n;
});
[Link](squared);
3. Event Bubbling and Event Capturing
Event Bubbling: Event flows from target to root.
Event Capturing: Event flows from root to target.
[Link]("click", handler, true);
4. IIFE (Immediately Invoked Function Expression)
An IIFE runs immediately after definition.
(function () {
[Link]("This is an IIFE");
})();
5. Closures
A closure allows an inner function to access outer function variables.
function outerFunction(outerVariable) {
return function innerFunction(innerVariable) {
[Link](outerVariable, innerVariable);
};
}
6. setTimeout and setInterval
setTimeout runs once after delay.
setInterval runs repeatedly.
setTimeout(() => [Link]("Hello"), 2000);
setInterval(() => [Link]("Hi"), 3000);
7. Callback Function
A callback is a function passed as an argument and executed later.
8. Promises
A Promise represents future completion of async task.
const myPromise = new Promise((resolve, reject) => {
resolve("Success");
});
9. Asynchronous Programming
Allows non-blocking execution using callbacks, promises, async/await.
10. Async and Await
Simplifies promise handling.
async function fetchData() {
const data = await fetch(url);
11. Event Loop
Manages call stack and queues for async execution.
12. call, apply, bind
Used to control 'this' context in functions.
13. Event Delegation
Uses event bubbling to handle events at parent level.
14. Debouncing and Throttling
Controls rate of function execution.
15. Hoisting
Declarations are hoisted, not initializations.
16. Promise vs Async/Await
Async/Await is syntactic sugar over promises.
17. reduce() Method
Used to accumulate values.
const sum = [1,2,3].reduce((a,b)=>a+b,0);
18. Currying
Transforms a function with multiple args into nested functions.
19. Generators
Functions that can pause and resume using yield.
20. WeakMap and WeakSet
Allows garbage collection of objects.
21. Shadow DOM
Encapsulates DOM and styles for web components.
22. Memory Management
Handled via garbage collection (mark and sweep).
23. Shallow Copy vs Deep Copy
Shallow copy copies references, deep copy duplicates objects.
24. JavaScript Strict Mode
"use strict" enables safer JavaScript execution.