What is the purpose of the map() function in JavaScript?
- The
map()function is used to iterate over an array and apply a transformation or computation on each element, returning a new array with the transformed elements (Built In).
What is the difference between splice() and slice()?
splice()modifies an array by adding, removing, or replacing elements, whileslice()creates a new array containing a portion of the original array without modifying it (Built In).
How do you remove duplicates from an array in JavaScript?
- You can use the
Setobject or thefilter()method along withindexOf()to remove duplicates from an array (Built In).
What are closures in JavaScript?
- Closures are functions that have access to variables from another function’s scope. This happens due to the function being defined within the other function, allowing access to its local variables (Built In).
Explain the difference between == and ===.
==checks for equality of value, performing type conversion if necessary, while===checks for both value and type without performing any type conversion (Guru99).
How can you check if an array includes a certain value in JavaScript?
- The
includes()method can be used to check if an array contains a specific value, returning true if it does and false otherwise (Built In).
What is the difference between var, let, and const?
varhas function scope and can be re-declared and updated.lethas block scope and can be updated but not re-declared.constalso has block scope but cannot be updated or re-declared (zety).
How do you handle asynchronous code in JavaScript?
- Asynchronous code in JavaScript can be handled using callbacks, Promises, and
async/awaitsyntax (Guru99).
What is the purpose of the reduce() function in JavaScript?
- The
reduce()function reduces an array to a single value by applying a function to each element and accumulating the result (Built In).
What is the fetch() function used for in JavaScript?
- The
fetch()function is used to make asynchronous HTTP requests, returning aPromisethat resolves to the response from the server (Built In).
.png)
Comments
Post a Comment