Jump to content

nested if else vs logical operators


TheOneTrueVlad
 Share

Recommended Posts

I have 3 variants of code that all do the same thing.

Is there a best practice for choosing?

Is it just appearance and ease of following or is there a technical reason to use one over the other?

/*if ( ($(window).width() < 535) || ($(window).height() < 700) ) {     if (scrollTop > stickyNavTop) {        jQuery('body').addClass('stickynav');    } else {        jQuery('body').removeClass('stickynav');     } } else {    jQuery('body').removeClass('stickynav'); }
if ( (scrollTop > stickyNavTop) && ( (($(window).height() < 700) || ($(window).width() < 535)) )) {    jQuery('body').addClass('stickynav');} else {    jQuery('body').removeClass('stickynav'); }
if ( ((scrollTop > stickyNavTop) && ($(window).height() < 700)) || ((scrollTop > stickyNavTop) && ($(window).width() < 535)) ) {    jQuery('body').addClass('stickynav');} else {    jQuery('body').removeClass('stickynav'); }
Cheers
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...