Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off “unreachable code after return statement” warning

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?

like image 397
dakab Avatar asked Nov 11 '15 11:11

dakab


1 Answers

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

}
like image 173
pauloz1890 Avatar answered Sep 28 '22 23:09

pauloz1890