Closed Bug 759570 Opened 13 years ago Closed 3 years ago

When using OR in Javascript IF test, instead of ||, the JS engine think a ) is missing.

Categories

(Core :: JavaScript Engine, defect)

12 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: pl.lamballais, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0 Build ID: 20120420145725 Steps to reproduce: // Using AND instead of && in IF test work correctly, // but use of OR instead of || don't work. val_etat="*"; if ( (val_etat=="*") OR (val_etat=="+")) { alert("coucou"); } else { alert("no work"); } val_etat="*"; if ( (val_etat=="*") || (val_etat=="+")) { alert("coucou"); } else { alert("no work"); } /* Exception: missing ) after condition */ Expected results: if AND work like && so OR must work like ||
Does it work in other Javascript Engines like the Safari one ?
In fact no. From a logical point of view, it you can use the "text" version of the operator in one case, it seems to be logical to be able to use it in all cases. I program on the internet for some years (start in 1997!) and never discovered that, maybe because I used only && and ||. 8-) So, not really a bug but a "logicial point of view". Notice the Firefox JS Engine tells ") is missing" (which can be confusing) but the Chrome JS Engine indicate "Unexpected identifier". Maybe changing the debug text would be nice.
(In reply to Pierre-Louis Lamballais from comment #0) > // Using AND instead of && in IF test work correctly, Doesn't seem to. (In reply to Pierre-Louis Lamballais from comment #2) > Notice the Firefox JS Engine tells ") is missing" (which can be confusing) > but the Chrome JS Engine indicate "Unexpected identifier". Maybe changing > the debug text would be nice. This seems fair.
Assignee: nobody → general
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Assignee: general → nobody
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.