• Fargeol@lemmy.world
    link
    fedilink
    arrow-up
    105
    ·
    edit-2
    21 hours ago

    NaN minutes later, a truck arrives in the alley, its license plate reads “undefined”. Someone gets out of the vehicle
    “I have something for you”
    He gives you a package. You open it. It’s an [object Object]

  • Scoopta@programming.dev
    cake
    link
    fedilink
    arrow-up
    36
    arrow-down
    5
    ·
    1 day ago

    As someone who mostly avoids JavaScript, I don’t see the IT in this image, I just see a bad language I avoid!

  • mumblerfish@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    23 hours ago

    I got one of those too. I called the customer service to get another path home because of disturbances, and they just have robot answering. The robot started halfway through the call just reading pure json at me, and then said “to get this information as a message press 1” or something. This is what I got:

    Here is your journey from undefined to undefined: BUSS 506 towards Karolinska sjukhuset 09:36 from undefined 10:18 arrived at undefined. Link to your journey.

  • glorkon@lemmy.world
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    edit-2
    22 hours ago

    I’m an old fuck and I started to code in the late 80s. Fast forward 30 years, I once had to work at a WeWork. One day, directly outside of my small office space, I swear to god, a fucking hipster kid with a Macbook under his arm practiced skateboard moves. That was the exact moment I started hating working in IT. It’s also what I think every Javascript coder looks and acts like.

  • Viking_Hippie@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    7
    ·
    21 hours ago

    I’m no acupuncturist, but I’m pretty sure that it’s SUPPOSED to say “naan minutes”, which is time spent enjoying delicious Indian flatbread.

    I guess you just eat your naan and then your ride arrives to ask you if you have any leftovers? 🤷

        • squaresinger@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          22 minutes ago

          Sure, but the main issue here is that JS doesn’t only auto cast to more generic but in both directions.

          Maybe a better example is this:

          "a" + 1 -> "a1"
          "a" - 1 -> NaN
          

          With + it casts to the more generic string type and then executes the overloaded + as a string concatenation.

          But with - it doesn’t throw an exception (e.g. something like “Method not implemented”), but instead casts to the more specific number type, and “a” becomes a NaN, and NaN - 1 becomes NaN as well.

          There’s no situation where "a" - "b" makes any sense or could be regarded as intentional, so it should just throw an error. String minus number also only makes sense in very specific cases (specifically, the string being a number), so also here I’d expect an error.

          If the programmer really wants to subtract one number from another and one or both of them are of type string, then the programmer should convert to number manually, e.g. using parseInt("1") - parseInt("2").