Turn off “unreachable code after return statement” warning

dakab picture dakab · Nov 11, 2015 · Viewed 17.7k times · Source

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?

Answer

pauloz1890 picture pauloz1890 · Dec 30, 2015

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);

}