There is an issue I cannot seem to get away from, even if I'd like to.
Recently I edited a bizarre question from a new JavaScript programmer with some strange ideas. He had a long line where you couldn't really see his double assignment so well. It had a horizontal scroll bar, and unnecessary scroll bars on code excerpts are a pet peeve of mine:
https://stackoverflow.com/posts/26302879/revisions
Having delved (I thought) into semicolon insertion issues, I believed I'd done a legal transformation. A comment appeared, and was upvoted:
Did you check for syntax errors? Because while semi-colons are optional, their omission (given the linebreaks in your shown code) should generate quite a few errors.
So I was the one putting in the linebreaks, here. I asked the commenter to clarify because I didn't think that was an issue. No response was raised.
It was already a sore spot for me, because one of my few on-StackOverflow.com "in the negative total" downvoted questions (since compensated by "meta effect", thanks but stop upvoting it) was this one:
Are there semicolon insertion dangers with continuing operators on next line?
I bountied it for 100 points just to draw attention to it enough to get it upvoted from the negative, because I didn't feel like whining on Meta. And the bounty raised it to zero and I thought the issue was settled. Now I feel like whining, because that question just got downvoted again, and I still don't have a response from the person who said the newlines were a problem in the other (seemingly unrelated) edit.
(The code has problems, of course, but I don't believe the newlines added any new ones.)
Am I on crack and/or is this JavaScript cargo cult behavior? Note the "That is rubbish." answer to my claim that it's often recited. If it's rubbish, why do I see this so frequently?
If it's rubbish, why do I see this so frequently?
Probably because of people encountering the behavior but not understanding all the cases where it can or cannot happen. – nhahtdh Oct 13 '14 at 2:57goto
in the code, see how that pans out :) – Hans Passant Oct 13 '14 at 8:11new
(though it's not really needed), butwith
kills performance, andgoto
doesn't even work in javascript. – John Dvorak Oct 16 '14 at 13:26window.undefined
with some value it shouldn't have. ES5 fixes that by makingwindow.undefined
unwritable - but it's still a silent error. – John Dvorak Oct 16 '14 at 14:11