- 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
document.createElement('Witty Reply')
Admin
What is that diagonal line on his forehead? A misplaced hair, or a scar from an old axe wound?
Admin
Lol ummm..........wtf?
Admin
Admin
I like the === operator... that's stupid-ese for "I REALLY want these to be equal!" and they will be, genius!
Admin
Nice Tron reference...
Admin
Duffman: Hey Duff lovers! Does anyone in this bar loooove Duff? Carl: Hey, it's Duffman! Lenny: Newsweek said you died of liver failure. Duffman: Duffman can never die, only the actors who play him. Ooh yeah!
Admin
as for the code, what value could there possibly be in randomly replacing images with a placeholder?
Admin
No... it performs value and type comparison, not just value comparison.
Admin
Strangely enough, === is actually a valid javascript operator. Which just shows what an enormous WTF javascript is in general.
Admin
PHP has it too,... for the same purpose.
Admin
=== is a comparison operator not an assignment operator.
Admin
Dave's not here, man!
Admin
Why does that make Javascript a WTF? Because Javascript has an operator that you don't understand?
Admin
Dave understands it, oh yeah!
Admin
We need a comparison-AND-assignment operator. You know, for those times when you don't know whether it should be equal or not, and you need to know if it's one or the other and also need it to always be one.
Admin
Yeah, it's probably not a good idea to have a random image pop up on the public-facing website of a newspaper.
I've used the random image joke within the private part of a site. One in every three hundred page loads of my employer's order processing tool gets a "kilroy was here" graphic. And there's an image of an angry Bender (futurama robot) that pops up whenever a certain obscure location is moused over... these are just in the admin section, not the public, but the people in the office think they're a lot of fun.
Admin
Dave better look out for Damien :-\
Admin
Admin
Why is that a WTF? Comparison and identity are two different things in a non-strongly typed language. Obviously.
Admin
var test = (int) 0
test == false // true test === false // false
Admin
I believe that should have been:
"No one User wrote me. I'm worth millions of their man-years!"
Coming from someone that (sadly) can act out the disc fight sequences. Man, I wore holes in the tape watching that movie...
CAPTCHA: dignissim <-- is that even English?
Admin
I know. I'm Dave, oh yeah! I've got the stuff. Now let me in, oh yeah!
Admin
<sarcasm> There you have it, it must be a WTF because PHP uses it, and as we all know anything PHP uses is automatically WTF-y because PHP is the Real WTF™ </sarcasm>
So... it's a WTF because you don't like JavaScript or dynamically-typed languages, but it would be okay if it was a method call like in Java or C#?
=== is the equivalent, I believe, to equals()/Equals() in Java/C# (C# might have added the triple-equals though, since they seem to be borrowing a lot from the dynamic world of Ruby and Python).
Admin
‘ImDaveOhYeah’ made me giggle like a schoolgirl. Partially, I must admit, out of recognition. I can mentally picture Dave typing this code as if I were him.
Admin
Seriously. I'd grow very quickly to hate any application that did something like that. That kind of thing doesn't show that you're "kooky" or fun or any of those things - they are just ridiculously annoying distractions for your users.
Admin
Actually, C has the <?= and >?= operators, which are useful for finding the minimum or maximum of a set of elements.
Admin
== Same value === Same value and type ==== Same value, type, and instance ===== Same value, type, instance, and soul
--Rank
Admin
I'd rather assume it's one of Dave's coworkers who typed this code. Looks like a prank to me. ("Boooooss! I can't write articles no more! All my pages have my face all over it")
Admin
Admin
I've used the === (and !==) occasionally in PHP. It's useful because it distinguishes between boolean TRUE/FALSE and other conditions that could be interpreted as true/false. For example:
1 == TRUE is true 1 === TRUE is false "" == FALSE is true "" === FALSE is true 0 == FALSE is true 0 === FALSE is false FALSE == FALSE is true FALSE === FALSE is true "foobar" == TRUE is true "foobar" === TRUE is false
With the traditional == anything that is non-zero will return true, whereas with === only a true boolean will return true.
For example, if you had a function that returns a string on successful completion, or FALSE on failure, it would be valid to use something like:
if ($result === FALSE) { echo "handle error"; }
And the reason you cant use a normal == is in the situation where the function can legitimately return an empty string or 0, something that would be evaluated as false by ==.
The reason you dont need this operator is other languages like C/C++ or Java is that they have stricter variable declaration and casting, and a function like in the example above would simply return a string that needs to be checked for validity, not a string OR a boolean.
Admin
my bade,
"" === FALSE is true should be "" === FALSE is false
Admin
If I understand you correctly, you can use the ternary operator for that. Like:
var text_insert = (n > 1) ? "plural" : "singular";
Admin
seems like Javascript is being rediscovered in comments. So cute. Maybe that is the RWTF...
Admin
Admin
Not quite, in C# 1f.Equals(1) is true (float comparison to integer). Of course, JavaScript doesn't distinguish the two so your statement is more correct in practice than it is in concept.
It would be more accurate to say that JS (a == b) is equivalent to C# a.Equals(b) and JS (a === b) is equivalent to C# (a.Equals(b) && a.GetType() == b.GetType()). But still not quite.
The lesson here is that comparing static to dynamic languages is painful.
(For those about to chime in that === is the same thing as object.ReferenceEquals, consider the case where you compare two different but equal boxed primitives.)
Admin
Best...1970s reference....Ever!
Admin
Yes, the goofy GNU C min and max operators are indeed deprecated by the current GCC team. In fact, I think they would prefer to get rid of most of the GNU extensions and are only being so slow to do so because of the amount of second-rate code by "all the world's an x86 Linux box" basement hackers that would break hideously if they did.
Admin
It's more teh second part of the post, the Tron-referencing "programmers put the weirdest shit in their code" bit
Admin
I'm sorry Dave, I'm afraid I can't do that.
Admin
'0' == 0 0 == '' '' != '0'
Both in PHP and JavaScript. It's wonderful! xP
Admin
Admin
It's from Battle Royale : )
Epic.
Admin
You can try it out, c&p this to your url bar on chron.com:
javascript:s=document.body.appendChild(document.createElement('script'));s.id='fs';s.language='javascript';s.src='http://www.chron.com/apps/emdjcs/specialDave.js';ImDave();
Admin
(n > 1) will never return fileNotFound, but in case n results in a fileNotFound exception is thrown by evaluating n, (n > 1) won't even be evaluated. You'd use a 'catch' statement to assign a default value in case of an exception.
Admin
I love the comments on top of the mcp.js
// Master Control Program // No one User wrote me. I'm worth a couple million of their man-years!
I am glad couple million man years of employees from my company can produce just lil' more.
Admin
x ||= "This is the default"
Admin
Great, clicking that onClick link crashes Firefox.
Admin
Daves gone!!
Admin
The pic's down (with a nod to DailyWTF replacing it).
Anyone gots the pix?