- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First! First! First! Fifth!
Admin
Probably submitted by a Lawful Good Codemonkey?
Admin
The usage of
var fvalue=5;
to break out of the loop is also interesting. Some pre-junior programmer had probably just learned about eval and loops and hacked the thing together before learning about "advanced" flow control like continue/break.Admin
Also curious about the re-declaration of
fvalue
. I don't know all the ins/outs of JS scoping, hoisting, etc. for variables, but reading what appears to be a new local variable getting declared inside the do/while seems wrong. It may be "correct"/fine but IMO it should not be.Admin
Could be. Or it could be someone thinking he was clever and wanting to add a bit of flare to his code. Kind of like using goto instead of return to jump back where you came from in the good old days. And whilst we might dislike the idea on an intellectual level I know I won't be casting the first stone.
Admin
So we have fvalue == 1 or fvalue == 5 and the test fvalue < 3. Is this a new take on true, false, file_not_found meme?
Admin
Ah, I meant to comment on that in the article, but was overwhelmed by the awfulness of all the rest and forgot. In JavaScript, all variables are hoisted to the function level when declared with
var
. Thelet
keyword was added to support block scoping. So this would probably throw a linter complaint (hah, like they're using a linter), but runs fine and doesn't actually redeclare the variable.Admin
Now I do wonder what the argument
myform
may actually be. Is it a string? Like "document.forms.myform"?It is so close and still that far at so many aspects… (There is a notion of loops, but not really. There is a notion of break conditions, but not really. There is a notion of object hierarchies, but not really. There is a notion of accessors, but not really. I stand in awe.)
Admin
Maybe I'm expecting too much of this person, but surely they knew JavaScript could do this much easier (and we can at least pretend its safer too:
window[myform][myselect].options[i];
its still a wtf but far better than an eval(!)
Admin
I've seen such eval things from people who were not aware that a.b and a["b"] is the same in JavaScript. Or that all global variables are inside the window object.
Mostly people who were mainly coding in Java or C#, and had to use JavaScript snippets on the Web (as GWTand friends is too much overkill).
Maybe, with all that node.js and serverside JavaScript, that problem will disappear eventually. But I'm not holding my breath.
Admin
I guess, this was also some cargo cult from the kind of code DreamWeaver generated. Why DreamWeaver did so, in the first place, was always a mystery to me.
Admin
This looks like lootbox coding to me. Writing random lines of codes till the somewhat expected result pops up and then push it to master.
Admin
I highly recommend https://essayshark.com/term-papers-online.html for all your college essay needs. I was in a time crunch and needed a professionally written essay, and EssayShark exceeded my expectations. The process was seamless, from placing my order to receiving a high-quality essay that was perfectly tailored to my requirements. Their team of writers knows how to create essays that truly stand out. My professor was impressed, and I received a top grade. If you want top-notch essay help, EssayShark.com is the best choice!