alert(a);
// gives ==>
function a() {
x = a == b && c == d;
if (a == b && (c == d)) {
p();
}
}
/*
Here all parenthesis of first expression in the function was striped
off
"x = (a == b) && (c == d) ;" ==> "x = a == b && c == d;"
But for the next statement with similar conditional expression the
last parenthesis is not removed.
ie, "if ((a == b) && (c == d) ) {" ==> "if (a == b && (c == d)) {"
now if we add an assignment operator in conditional expression, you
will see the problem is gone.
ie, " if(x=(a == b) && (c == d) ) {" ==> "if (x = a == b && c == d)
{"
So question, is this a bug or it is working as per designed ?
*/
function a() {
x = (a == b) && (c == d) && (e == f) && (g == h) ;
if((a == b) && (c == d) && (e == f) && (g == h) );
if(x=(a == b) && (c == d) && (e == f) && (g == h) ) ;
while((a == b) && (c == d) && (e == f) && (g == h) ) ;
while(x=(a == b) && (c == d) && (e == f) && (g == h) ) ;
for((a == b) && (c == d) && (e == f) && (g == h) ;;) ;
for(;(a == b) && (c == d) && (e == f) && (g == h) ;) ;
for(;x=(a == b) && (c == d) && (e == f) && (g == h) ;) ;
for(;;(a == b) && (c == d) && (e == f) && (g == h) ) ;
do{}while((a == b) && (c == d) && (e == f) && (g == h) ) ;
do{}while(x=(a == b) && (c == d) && (e == f) && (g == h) ) ;
}
// gives ==>
function a() {
x = a == b && c == d && e == f && g == h;
if (a == b && c == d && e == f && (g == h)) {
}
if (x = a == b && c == d && e == f && g == h) {
}
while (a == b && c == d && e == f && (g == h)) {
}
while (x = a == b && c == d && e == f && g == h) {
}
for (a == b && c == d && e == f && g == h;;) {
}
for (; a == b && c == d && e == f && (g == h);) {
}
for (; x = a == b && c == d && e == f && g == h;) {
}
for (;; a == b && c == d && e == f && g == h) {
}
do {
} while (a == b && c == d && e == f && (g == h));
do {
} while (x = a == b && c == d && e == f && g == h);
}