unreachable code after return statement

I have several messages in the Firfox debugger: "unreachable code after return statement".

Here are some examples that trigger the problem.

 this.GetDefaultHostName = function () {
      var Result = "";
      Result = "";
      return window.location.hostname;
      return Result;
    };
    this.GetDefaultPort = function () {
      var Result = 0;
      Result = 8888;
      return window.location.port;
      return Result;
    };
    this.GetDefaultPathName = function () {
      var Result = "";
      Result = "";
      return window.location.pathname;
      return Result;
    };

The return lines were never executed, because the function is already terminated at the first return.

copied from
"Warning: unreachable code after return statement - JavaScript | MDN"

Warning: unreachable code after return statement

The JavaScript warning "unreachable code after return statement" occurs when using an expression after a return statement, or when using a semicolon-less return statement but including an expression directly after.

Warning: unreachable code after return statement (Firefox)

Unreachable code after a return statement might occur in these situations:

  • When using an expression after a return statement, or
  • when using a semicolon-less return statement but including an expression directly after.

When an expression exists after a valid return statement, a warning is given to indicate that the code after the return statement is unreachable, meaning it can never be run.

Why should I have semicolons after return statements? In the case of semicolon-less return statements, it can be unclear whether the developer intended to return the statement on the following line, or to stop execution and return. The warning indicates that there is ambiguity in the way the return statement is written.

Hi,

We have fixed the warning. Thanks for reporting. Next version of TMS WEB Core will address this.