I am coming from a Java background. In java if I have a method like below:
public static String foo()
{
return "foo";
System.out.println("x");
}
I will get Compilation error :
error: unreachable statement
System.out.println("x");
Now I understand that JS,and Java is totally different language. But I wanted to be sure, if what I understood is correct.
Following code works, fine without any error, warning (I read that in Firefox, we do get warning)
"use strict";
function createIncrementor() {
console.log('Logging before return .. ' );
return 3;
console.log('Logging.. after return' );
}
var inc = createIncrementor();
console.log(inc);
console.log('Logging.. after return' );
is ignored, without Warning/Error or so in Normal run. I saw that ESlint has a rule to check this.
So question is :
Is this expected or I need to enable some setting/config (use strict didn't do anything though)? To check such errors, what is the recommendation? Always use ESLint?