Let's Learn Vocabulary
Frequently Asked Questions
1.The difference between var, let, and const?
Var is function-scoped and can be redeclared or updated.
let and const are block-scoped-let can be updated, but const cannot be reassigned.
2.The difference between map(), forEach(), and filter()?
forEach() executes a function on each array element but returns nothing.
map()returns a new array with transformed elements, while filter()returns a new array with elements that pass a condition.
forEach() executes a function on each array element but returns nothing.
map() returns a new array with transformed elements, while filter() returns a new array with elements that pass a condition.
3. Explain arrow functions and how they are different from regular functions.
Arrow functions are a concise way to write functions using =>, they inherit this from the surrounding context, don’t have their own arguments, and cannot be used as constructors, unlike regular functions.
4.how JavaScript Promises work?
JavaScript Promises represent an asynchronous operation that can resolve with a value or reject with an error, allowing .then() and .catch() to handle the results.
5.How closures work in JavaScript?
Closures in JavaScript occur when a function remembers and can access variables from its outer scope even after that outer function has finished executing.