Top 10 Javascript Interview Question With Answers | letsbug
Javascript Interview Questions
1. What is Rest Parameters?
Answer:
The Rest parameter syntax allows a function to accept indefinite number of arguments as an array.
2. What is Rest Operators?
Answer:
The Rest Operator allows us to call a function and then access those excess arguments as an array.
3. What is Currying functions?
Answer:
Currying is a function that takes one argument at a time and returns a new function expecting the next argument.
4. Immediately invoked functions example:
Answer:
(() => {})()
5. What is Call()
Answer:
The call() method calls the function with a given this value and arguments provided individually.
6. What is apply()
Answer:
The apply method calls the specified function with a given this value, and arguments provided as an array.
7. What is bind()
Answer:
The bind() method creates a new function that, when called, has its this keyword set the provided value, with a given sequence of arguments preceding any provided, when the new function is called.
8. Difference between splice and slice methods
Answer:
Slice return a piece of the array but it doesn't affect the original array.
Splice changes the original array be removing, replacing or adding values and returns the affected values.
9. What is Hoisting?
Answer:
Javascript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code.
10. What is Deep copy
Answer:
Deep copy makes copy of all the members of old object, and allocates seperate memory location for the new object and then assigns the copied members to the new object. Hence, both the objects (new and old) are independent of each other. If any modification is done on either of them other is not affected by it.