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

Popular posts from this blog

matlab - Deleting rows with specific rules -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -