What is the purpose of the “map” method in JavaScript? map() creates a new array with the results of calling a provided function on every element.
What is a promise in JavaScript? A promise is an object representing the eventual completion or failure of an asynchronous operation.
How do you handle errors in promises? Use .catch() or a try...catch block inside an async function.
Explain the concept of currying in JavaScript. Currying is transforming a function with multiple arguments into a sequence of functions each taking a single argument.
What is the purpose of the “reduce” method in JavaScript? reduce() applies a function to accumulate values in an array into a single result.
What is the difference between “null” and “undefined” in JavaScript?
null is an assignment value.
undefined means a variable has been declared but not assigned.
What are the different types of loops in JavaScript?
for, while, do...while
for...of, for...in
Array.forEach()
What is the difference between “let,” “const,” and “var” in JavaScript?
var is function-scoped, hoisted, can be re-declared.
let is block-scoped, cannot be re-declared in the same scope, can be reassigned.
const is block-scoped, cannot be re-declared or reassigned.
Explain the concept of event propagation in JavaScript. Event propagation includes capturing, target, and bubbling phases. JavaScript uses bubbling by default.
What are the different ways to manipulate the DOM in JavaScript?
getElementById(), querySelector(), createElement()
innerHTML, textContent, classList, setAttribute()
What is the purpose of “localStorage” and “sessionStorage”?
localStorage stores data with no expiration.
sessionStorage stores data for the session.
How do you handle asynchronous operations in JavaScript? Using callbacks, promises, or async/await syntax.
What is the purpose of the “forEach” method in JavaScript? forEach() executes a provided function once for each array element.
What are the differences between “let” and “var”?
let is block-scoped; var is function-scoped.
let cannot be accessed before declaration (Temporal Dead Zone).
Explain the concept of memoization in JavaScript. Memoization caches the results of function calls to avoid recalculating the same result.
What is the purpose of the “splice” method in JavaScript arrays? splice() adds/removes/replaces elements in an array in-place.
What is a generator function in JavaScript? A generator function (function*) can pause and resume execution using yield. It returns an iterator.
How does JavaScript handle variable scoping? Variables can be globally, function, or block scoped depending on how they are declared (var, let, const).
What is the purpose of the “split” method in JavaScript? split() splits a string into an array of substrings based on a specified separator.
What is the difference between a deep clone and a shallow clone of an object?
Shallow clone copies only references to nested objects.
Deep clone creates independent copies of all nested objects.
Explain the concept of the event delegation pattern. Event delegation attaches a single listener to a parent element to handle events from child elements via event bubbling.
What are the differences between JavaScript’s “null” and “undefined”?
null is intentional absence of value.
undefined means no value has been assigned.
What is the purpose of the “arguments” object in JavaScript? arguments is an array-like object accessible inside regular functions that contains the passed arguments.
What are the different ways to define methods in JavaScript objects?
Traditional function syntax
Shorthand method syntax
Arrow functions (not recommended due to this binding issues)
Explain the concept of memoization and its benefits. Memoization is storing the result of expensive function calls to improve performance for repeated inputs.
Post #2672
2.22K
- ❤ 2