Let's Learn Vocabularies
আপনি এখনো কোন Lesson Select করেন নি
একটি Lesson Select করুন।
Frequently Asked Questions
1. What is the difference between var, let, and const ?
var : is function-scoped, can be redeclared and updated, and
is hoisted with undefined. It's outdated and not recommended.
let : is block-scoped, can be updated but not redeclared, and is hoisted without initialization. It's ideal for variables that change.
const : is block-scoped, cannot be updated or redeclared, and is best for constants or objects/arrays that shouldn't be reassigned.
let : is block-scoped, can be updated but not redeclared, and is hoisted without initialization. It's ideal for variables that change.
const : is block-scoped, cannot be updated or redeclared, and is best for constants or objects/arrays that shouldn't be reassigned.
2. What is the difference between map(), forEach(), and
filter() ?
map() creates a new array by applying a function to each
element without modifying the original array. It's useful when you need to transform data.
forEach() simply iterates over an array and executes a function for each element but does not return a new array. It's ideal for tasks like logging or updating UI elements.
filter() returns a new array containing only the elements that satisfy a given condition, making it useful for extracting specific data from an array.
forEach() simply iterates over an array and executes a function for each element but does not return a new array. It's ideal for tasks like logging or updating UI elements.
filter() returns a new array containing only the elements that satisfy a given condition, making it useful for extracting specific data from an array.
3. Explain arrow functions and how they are different from
regular functions?
Arrow functions (=>) are a concise way to write functions in
JavaScript. They were introduced in ES6 and offer a shorter syntax compared to regular
functions.
4. How JavaScript Promises work ?
A Promise in JavaScript works as a placeholder for a future
value, handling asynchronous operations. It follows this flow:
1. Creation → A Promise is created with an executor function that has resolve (success) and reject (failure).
2. Pending State → The Promise starts in a pending state while the operation runs.
3. Resolved or Rejected → When the operation finishes:
* If successful, resolve(value) moves the Promise to fulfilled.
* If failed, reject(error) moves it to rejected.
4. Handling Results → .then() processes resolved data, .catch() handles errors, and .finally() executes cleanup code.
1. Creation → A Promise is created with an executor function that has resolve (success) and reject (failure).
2. Pending State → The Promise starts in a pending state while the operation runs.
3. Resolved or Rejected → When the operation finishes:
* If successful, resolve(value) moves the Promise to fulfilled.
* If failed, reject(error) moves it to rejected.
4. Handling Results → .then() processes resolved data, .catch() handles errors, and .finally() executes cleanup code.
5. How closures work in JavaScript ?
1. When a function is defined inside another function, it has
access to the outer function's variables.
2. If the inner function is returned or used later, it still retains access to those variables, even though the outer function has finished execution.
2. If the inner function is returned or used later, it still retains access to those variables, even though the outer function has finished execution.