Let's Learn Vocabularies
আপনি এখনো কোন Lesson Select করেন ন
একটি Lesson Select করুন।
আপনি এখনো কোন Lesson Select করেন ন
একটি Lesson Select করুন।
Frequently Asked Questions
1. what is the difference between var, let, and const?
- var: Function-scoped, can be redeclared & reassigned, hoisted with `undefined`.
- let: Block-scoped, cannot be redeclared, hoisted but not initialized.
- const: Block-scoped, cannot be reassigned, must be initialized at declaration.
2. What is the difference between map(), forEach(), and filter()?
- map(): Returns a new array with modified values.
- forEach(): Loops through elements but does not return a new array.
- filter(): Returns a new array with elements that satisfy a condition.
3. Explain arrow functions and how they are different from regular functions?
Arrow functions (`=>`) provide a shorter syntax and do not bind `this`.
Differences:
- No own `this` (inherits from parent scope).
- Cannot be used as constructors.
- No `arguments` object (use rest parameters instead).
4. How do JavaScript Promises work?
A Promise represents a future value that can be `fulfilled`, `rejected`, or `pending`.
- Use `.then()` for success handling.
- Use `.catch()` for error handling.
- Use `async/await` for cleaner asynchronous code.
5. How do closures work in JavaScript?
A closure allows a function to remember variables from its parent scope, even after the parent function has executed.
Example:
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1
counter(); // 2
1. what is the difference between var, let, and const?
- var: Function-scoped, can be redeclared & reassigned, hoisted with `undefined`.
- let: Block-scoped, cannot be redeclared, hoisted but not initialized.
- const: Block-scoped, cannot be reassigned, must be initialized at declaration.
2. What is the difference between map(), forEach(), and filter()?
- map(): Returns a new array with modified values.
- forEach(): Loops through elements but does not return a new array.
- filter(): Returns a new array with elements that satisfy a condition.
3. Explain arrow functions and how they are different from regular functions?
Arrow functions (`=>`) provide a shorter syntax and do not bind `this`.
Differences:
- No own `this` (inherits from parent scope).
- Cannot be used as constructors.
- No `arguments` object (use rest parameters instead).
4. How do JavaScript Promises work?
A Promise represents a future value that can be `fulfilled`, `rejected`, or `pending`.
- Use `.then()` for success handling.
- Use `.catch()` for error handling.
- Use `async/await` for cleaner asynchronous code.
5. How do closures work in JavaScript?
A closure allows a function to remember variables from its parent scope, even after the parent function has executed. Example:
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1
counter(); // 2