ollie Posted March 30, 2010 Posted March 30, 2010 I've spent alot of time writing javascript lately, mainly handling events. (I know this is a CAD board but the principal is the same) What I've realised is that i end up writing conditional statements with the same conditional statements for either result of the first for example: if( A == true){ if(c==d){ action(A+d) } else{ action(A+c) } } else{ if(c==d){ action(A+d+1) } else{ action(A+c+1) } } This is a relatively small example. My main reasoning is not creating unecessary local variable since js doesn't have manual garbage collection What are the communities thoughts on the matter? Ollie Quote
Lee Mac Posted March 30, 2010 Posted March 30, 2010 Perhaps use an 'if-else' structure? if ((c == d) && (A == true)) action(A+d) else if (c == d) action(A+d+1) else if (A == true) action(A+c) else action(A+c+1) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.