Javascript minimizing this if statement possible? -
i'm trying learn shorthand javascript stuck following one.
if (windowwidth >= 960){ widthofwindow = 1; yooucandoit() } else { widthofwindow = 0; $('#topbar').remove(); }
that code looks fine. it's unterstandable , has little duplication of code.
you can make short, if yooucandoit
function doesn't depend on widthofwindow
variable, uses side effects in conditional operators, has pretty bad code smell...
widthofwindow = windowwidth >= 960 ? yooucandoit(), 1 : $('#topbar').remove(), 0;
Comments
Post a Comment