What is tail call optimization in JavaScript?

What is tail call optimization in JavaScript?

a) A method where the last function call is optimized to prevent stack overflow
b) A method that increases the call stack size
c) A technique to sort elements faster
d) A function to prevent recursion

Answer:

a) A method where the last function call is optimized to prevent stack overflow

Explanation:

Tail call optimization is a technique used in JavaScript to optimize recursive functions. When the last action of a function is a call to another function, JavaScript can optimize it to prevent stack overflow by reusing the stack frame for the next function call.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top