- 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
waiting for frist, I shall return
Admin
Julio is first
Admin
Tell Julio to read this!
http://peace4patience.s3-website-us-east-1.amazonaws.com/blog.html#gaslights
Admin
... and don't forget the good old favourite of initialising it to false, and then setting it to false.
Maybe the writer of this code wanted the ability to put some internal debugging into the method, and so assigned the value of the function to a boolean so as to be able to put it into an alert. After all, it's important to check it returns "false" when the function is "undefined". The sky might fall otherwise.
Admin
Stephen, did you forget to take your meds?
Admin
Oh, it's probably simple: long ago, some clever coder set up a table of function-pointers (or the equivalent in JS) somewhere as a plugin-type inner platform layer and needed a way to denote the ones that weren't set. So, taking advantage of type fluidity, he picked this "undefined" constant rather than something sensible like, say, null. Then, much later, some not-so-clever coder saw several calls to this mysterious IsFunction and decided that it seemed like a good idea to use it for general defensive coding. And thus a cargo cult is born.
Admin
I feel like creating an IsFunction repo on GitHub. Surely everyone needs to depend on this.
Admin
Oh I'm long past the point of no returns for meds. The doctors just tell me to stay indoors, and don't walk in public without your leash!
Admin
No, put it on npm. Make sure it pulls in a few dozen dependencies "just because". When the entire internet uses it, try to delete the repo and watch it all burn.
Admin
Quick two questions for the experts:
How can I get this tweet read by the following people? Madonna, Ashley Judd, Linda Sarsour, Medea Benjamin, etc. etc. ? https://twitter.com/fun_stevehawkin/status/966651703511736320
Will the C&S guys be interested in a multi college fellowship regarding school violence prevention for their highly ironic 4-20 drug use marathon against mental illness?
Admin
That, I feel, would be a rather fine experiment. Make it so!
Admin
Did they also recommend unplugging your computer? Because, they should.
Admin
Admin
The real WTF is JavaScript. Oh how I loathe weakly-typed languages. You have to write so much more defensive code, especially when they do weird type coercions.
I was having trouble yesterday with getAttribute() and setAttribute(). Apparently, passing a string into the latter doesn't guarantee it'll come back out as a string with the former in IE (there's an optional flag to force strings). Thus when I was saving "11" and expecting to pass "11" into a function to get 11 for another function that need an integer, it just stopped executing. While trying to figure out what was going on, I saw how much code like IsFunction() that I had added to so many calls. This type of idiocy is rarely necessary in a real language.
Admin
Please see:
https://twitter.com/fun_stevehawkin/status/966748879227105280
Don't click links! XSS is dangerous!
Admin
wow, finally something amusing again. no made up booring backround story which just wastes 15 minutes of your life. good old wtf like those for which i started reading this site.
Admin
Wow, he's funny!
https://twitter.com/fun_stevehawkin/status/966761657350451200
Admin
"I feel like creating an IsFunction repo on -GitHub- npm. Surely everyone needs to depend on this." FTFY (also, I don't know how formatting works)
Admin
The weekly-typed will inherit the Earth. Then an inner platform of types will rise to power to rule them.
Admin
How come that spaceman's links never seem to be held for moderation? Wild conspiracy theory: spaceman is REMY PORTER!
Admin
For some reason, I suspect there's some backstory on this, like a boss insisting that "All function calls must be verified before being executed" or some such.
The poor coder probably whipped this up and either never tested it, or created it knowing that it was pointless but would satisfy his boss.
Admin
Some things will return undefined with their toString.
Which is great:
It was probably a stupid way to check for that. Loose comparison wont do that though, contrary to intuition.
That'll work. It's still a mystery though since when will you call a string? (You wont.)
It's then obviously been used for any case where undefined might be converted to string likely superstitiously.
The function should clearly be made terse:
You can fix it so that it works properly like this:
Or more explicitely:
This allows you to know if you actually have the string undefined or a string with the toString of undefined, but don't tell anyone about ECMA12's dirty little secret, string unmutation (very common with ints in most languages for a long time, for example x += 4, x -= 4). I'm joking but it wouldn't surprise me if this exists somewhere or somehow.
Thankfully this won't work:
Admin
Nope.
Protip: Try reading a book!
Admin
Are you suggesting there's a book that 🤷 should read that explains why your links never seem to be held for moderation? Or that confirms or denies that you are Remy Porter? Both of those are awfully specific for someone to write a book about.
Admin
I haven't done exhaustive research on it but thus far it seems like the moderation queue only applies to posts from a mobile device.
Unsolicited commentary: for a site where we ridicule bad developers, the site has its share of WTFs.