Is it good to use "return false"; basically say do nothing in if statement? For instance:
if (navigator.userAgent.match(/iPad/i) != null) { return false; } else { //Usual script here }
just wondering if there are any problems with this. I can use the if statement without else, but I just want to get an idea about this. I have a plugin that I don’t want to run on the iPad, and so I wrap it in conditional. Any comments would be appreciated!
Group 1 will say that this is a terrible practice, as it is difficult to implement.
Group 2 will say do it.
Group 3 will say do it, but in line 1
Group 4 will say don't use else
5 , , if, . AKA:
if (navigator.userAgent.match(/iPad/i) === null) { //Usual script here }
, .
, :
if (navigator.userAgent.match(/iPad/i) != null) return false; //Usual script here
" "... , . , , -, , .
, , false , , , , return true;.
false
return true;
, - . "" if, . :
if (navigator.userAgent.match(/iPad/i) == null) { //Usual script here }
, "" ( ).
snkmchnb, . , :
!(a && b) = !a || !b !(a || b) = !a && !b
, , . ,
!( (a && b || c) && (d || e) || f) = !((a && b || c) && (d || e)) && !f = (!(a && b || c) || !(d || e)) && !f = (!(a && b) && !c || !d && !e) && !f = ((!a || !b) && !c || !d && !e) && !f
, . , "< =" " > "
! (long_expression):
if (long expression) { } else { //do stuff here }
-, ,
var window.__page_loaded__; var Loadpage = function () { if(window.__page_loaded__ != undefined) { return; //The page has already laoded } //Proceed to load the page }
return;, , else, , Loadpage() - , .
return;
else
Loadpage()