When a return statement is executed, the function’s execution halts immediately and control returns to the calling code. The value specified in the return statement becomes the result of the function call. If no value is provided, undefined is returned instead. In memory, the stack frame for the function (containing local variables and return address) is popped from the call stack, freeing up resources.