Is there any difference between the below if statements
Whats the difference between this two
if (2&&4==2&&4) { /*Statements*/ }
if (2==2 &&4==4) { /*Statements*/ }
Is there any difference between the below if statements
Whats the difference between this two
if (2&&4==2&&4) { /*Statements*/ }
if (2==2 &&4==4) { /*Statements*/ }
They're very different.
2==2 && 4==4
This is comparing the two values on the left and the two values on the right and then ANDs the results together. So this statement is only true if both values on the left are the same and both values on the right are the same.
2 && 4==2 && 4
Because of the order of operations this will compare the two values in the middle first. If this is false then the whole statement is false. Otherwise it will AND that value with the values on the far left and right. If both of those are also true then the whole statement will be true.
12 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved