5
Situation
It was performing some maintenance functions on JS.
And a certain function I placed a return
in the midst of it, for the rest was no longer necessary.
On seeing from the comment the rest or delete, I kept the code there.
When reloading the page the console fires this message:
Syntaxerror: unreachable code after Return statement
Syntax error : code inaccessible after return instruction
Code
function ajustaTela(){
jQuery('.data').datepick();
return;
if(jQuery(document).innerWidth() < 1050){
jQuery("#panel-header #panel-header-content #menu_header li").css({'padding':'6px 5px'});
}else{
jQuery("#panel-header #panel-header-content #menu_header li").css({'padding':'6px 10px'});
}
jQuery('span.adicionar_favoritos').css('margin-left', ((jQuery('span.adicionar_favoritos').parents('div.panel_title').width() / 2)-15) + 'px');
jQuery('.data').datepick();
makeHeaderFixedSize();
}
Doubt
What possible problems can I have in keeping a code after the return
?
Obs
Browser : firefox 40.0
You can post the code here?
– PauloHDSousa
In my view, there is no problem in keeping code after Return if it is part of the logic, now keeping unused code can be a big problem, imagine if something unexpected happens and does not run Return, the code will run unused snippet may cause problems.
– Lucas Fontes Gaspareto
Which browser did you use? used some stricter directive?
– rray