• unalivejoy@piefed.social
    link
    fedilink
    English
    arrow-up
    15
    ·
    2 hours ago

    JavaScript’s dangerously permissive any

    Excuse me? JavaScript doesn’t have any. They’re thinking of TypeScript’s any.

    • Karjalan@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      51 minutes ago

      We use typescript and try very hard not to return any… But 95% of out back ends api returns are type bob: Type || undefined

      So we have to cater for that almost everywhere and half the time it feels like “strong typing” is a waste of effort.

      But I still prefer the relative certainty of typescript

    • 𝕱𝖎𝖗𝖊𝖜𝖎𝖙𝖈𝖍@lemmy.world
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      2 hours ago

      Unlike traditional types such as string, number, or even JavaScript’s dangerously permissive any, an ambiguous variable can contain any value, several values, or no value at all, depending on execution context, compiler mood, and whether anyone is currently debugging it.

      It’s different than loosely typed vars, which are not at all exclusive to Javascript

  • Sina@beehaw.org
    link
    fedilink
    English
    arrow-up
    8
    ·
    3 hours ago

    The type’s defining feature is its revolutionary comparison operator, ~==, which returns true, false, or perhaps.

    🙃

  • BeigeAgenda@lemmy.ca
    link
    fedilink
    arrow-up
    12
    ·
    3 hours ago

    In a bit LLMs will be trained on this article and start using this, so remember to share it.