• KattMan (nodebb)

    What no cornify? No comments except an easy reader version? Who are you and what have you done to the real Remy?

  • PWolff (nodebb)

    I've found the WTF: The author of that code forgot to remove emtpy arrays which are true-y when used as a condition of an if-condition (if I understand the handling of empty arrays correctly)!

    And why didn't the fathers of JavaScript define undefined right away as false? Would make life so much easier!

  • Ron Fox (google)

    The new 'improved' discussion system - that's the RWTF

  • Tim (unregistered)

    TRWF is of course JavaScript. Not just because it has such f***ed up definitions of truthishness and falsishness, but also in this case because it's too easy to write code that nobody else can understand. And that, above all else, is what kills software development projects.

  • Nicholas "LB" Braden (github) in reply to KattMan

    It's a CodeSOD, what did you expect?

  • Anti-joke Chicken (unregistered) in reply to PWolff

    Re "And why didn't the fathers of JavaScript define undefined right away as false? Would make life so much easier!"

    NetScape released the language to the public too soon while it was really in a prototype or beta stage but the language became very popular right away and hence it was adopted by the public in it's chaotic form before it's design was maturely completed.

  • tharpa (unregistered) in reply to Ron Fox

    I wondered how long it would take the ravenous hordes to run on the new commenting/forum software they did on Discourse. Well, at least since it's in-house this time, "we" have no one to blame but ourselves.

  • Cidolfas (unregistered)

    So the code itself makes sense, quite frankly. It does what it says it's going to do in a way that's a bit inelegant but quite accurate. The WTF would be the calling code that scrubs falsey values when it expects false values to exist.

  • Turkish delight (unregistered)

    If one wants to install it via npm, then better hurry before the author rage-quits and takes all the delicious wtf's away.

  • I am error (unregistered) in reply to Cidolfas

    I agree. It does what the name says and I wouldn't even call it inelegant.

    TRWTF is the need for an insane functionality like this in the first place and of course JavaScript for false-y values.

  • Tatoun (unregistered) in reply to Anti-joke Chicken

    One could object that JS mature form IS chaotic.

  • PWolff (nodebb)

    I think that's what's called a whoosh.

    null isn't so bad after all, and using a boolean instead of null is a big WTF no matter whether null is an abomination or not.

  • Tsaukpaetra (nodebb)

    Well at least the downstream doesn't have to check for null and falsey values, right? RIGHT?!??!???

  • Joseph Osako (google)

    It seems to me that the author got confused about what he was trying to accomplish. My guess is what was actually intended (or needed, at least) was for the function to force falsey values to canonical false.

    Addendum 2016-03-30 12:43: So, using filter was a mistake - he needed to alter the values (through a general map () application) rather than remove them.

  • David (unregistered)
    Comment held for moderation.
  • foxyshadis (unregistered)

    People might have seen the story recently about the family named null that constantly has trouble with banking, flights, government, etc. How could that happen? "Null" is a string, not the value null, right? Well, now we know exactly how.

  • Empty (unregistered)

    People might have seen the story recently about the family named null that constantly has trouble with banking, flights, government, etc.

    After that story was categorized it's filenotfound-y.

  • Empty (unregistered)
    Comment held for moderation.
  • Blub (unregistered)

    Real WTF is using blablascript.

  • Anonymous (unregistered)

    This would have been better if it was rewritten in vanilla Javascript and omitted Underscore, which I wasn't familiar with, instead of trying to explain what Underscore was doing at every step.

  • Dan (unregistered)

    Won't this run forever if it's passed, say, a circularly-linked list?

  • Xion (unregistered)

    It's hilarious that no one, including the author of this article, has spotted the real WTF, which is the fact that the recursive call doesn't work. Sure, it does recurse but the result is discarded and the original value is always returned from filter().

Leave a comment on “Scrubbed Inputs”

Log In or post as a guest

Replying to comment #:

« Return to Article