6

In JavaScript development, I frequently return from execution to have an inartificial breakpoint:

var args = arguments;
return console.log(args); // debug
criticalProcessing(args);

Chrome and others are okay with it, but unfortunately for debugging in Firefox:

Starting with Gecko 40 (Firefox 40 / Thunderbird 40 / SeaMonkey 2.37), a warning is shown in the console if unreachable code is found after a return statement.

Firefox’ about:config provides quite some flags to adjust the development environment. Sadly, I didn’t find a corresponding setting (nor a solution elsewhere).

Is there a way to turn of the “unreachable code after return statement” warning?

dakab
  • 4,576
  • 8
  • 38
  • 56
  • 2
    This is a problem because some libraries like bluebird optimize for Chrome and putting an eval after the return statement makes the V8 engine run faster. – user2867288 Feb 16 '18 at 02:32
  • @user2867288 can you show maybe any proof on this? We are facing the same issue but require some citation before closing bugtickets for the customer - but I fail to find any. – ForestG Apr 13 '21 at 08:48
  • 1
    @ForestG https://stackoverflow.com/questions/24987896/how-does-bluebirds-util-tofastproperties-function-make-an-objects-properties – user2867288 Apr 13 '21 at 18:15

1 Answers1

4

The only way I know of getting around this warning is to put a condition that's always true in the return line:

function myFun() {
     var args = arguments;

     if (1) return console.log(args);

    // unreachable code goes here
    criticalProcessing(args);

}
pauloz1890
  • 761
  • 1
  • 10
  • 20