I recently came across the following syntax error:
if (button=="init" || "show_selected" || "show_all") {
Of course this should have been:
if (button=="init" || button=="show_selected" || button=="show_all") {
HOWEVER, the original statement seemed to be working perfectly in Chrome, FF and IE9!?!? I only chanced upon my mistake while adding a new option.
To clarify, "init", "show_selected" and "show_all" are string arguments used when calling the function; e.g.
onclick=myFunction("init");
I'm sure I remember trying this kind of shorthand early on when learning JS and finding out very quickly that it didn't work.
I've already corrected the code anyway, but it's annoying me that I can't see why it was working.
Can anyone shed light on this enigma?
Aucun commentaire:
Enregistrer un commentaire