In JavaScript, when both try and finally blocks have return statements, the finally block will always take precedence over the try and catch blocks.
The return statement in a try block does not immediately exit the function. Instead, it creates a Completion Record that is kept internally by the JavaScript engine.
The finally block is always executed, regardless of whether there was an error in the try block or an exception caught in the catch block.
If the finally block includes a return statement, it will override any previous return statements from the try or catch blocks, and becomes the final return value of the function.