Lemmy.one
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 8か月前

Which of these javascript expressions is false?

lemmy.ml

message-square
13
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
81

Which of these javascript expressions is false?

lemmy.ml

☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 8か月前
message-square
13
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
alert-triangle
You must log in or # to comment.
  • davel [he/him]@lemmy.ml
    link
    fedilink
    English
    arrow-up
    30
    ·
    8か月前

    Definitionally in IEEE floating point, NaN is not equal to anything, including itself. The only real abomination here is B:

    > Math.min()
    Infinity
    > Math.max()
    -Infinity
    > 
    
    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      21
      ·
      8か月前

      I mean, B does make some amount of sense, if you realize that it’s supposed to give you the maximum among the parameters (so you’d normally call it as Math.max(5, 3) === 5).

      Well, and you can call that with zero parameters, because you can spread an array into it, which might have zero length. And then given these conditions, and if you don’t want to throw an error, then -Infinity is kind of the least bad remaining option, as it’s likely to generally work with the rest of your logic.

      • NewDark [he/him]@hexbear.net
        link
        fedilink
        English
        arrow-up
        5
        ·
        8か月前

        I love javascript. It’s so insane in such fun ways to prevent itself from throwing errors. It’s got like a naive cute charm to it ya know?

      • mathemachristian [he/him]@hexbear.net
        link
        fedilink
        arrow-up
        4
        ·
        8か月前

        thats how we often do it in math. The minimum over the empty set is ∞

  • ThotDragon@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    6
    ·
    8か月前

    I’m guessing C

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      ·
      8か月前

      yup

    • CapriciousDay@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      8か月前

      deleted by creator

  • 🍉🌻reStudy 🚀:neocat_laptop_owo:@infosec.exchange
    link
    fedilink
    arrow-up
    4
    ·
    8か月前

    deleted by creator

  • salmoura@lemmy.eco.br
    link
    fedilink
    arrow-up
    3
    ·
    8か月前

    It can’t be anything other than B, right?

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      8
      ·
      8か月前

      it’s not B

  • lowleveldata@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    8か月前

    A && B && C && D

  • twice_hatch@midwest.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    8か月前

    Moot! Those ALL fail code review!

  • ClathrateG [none/use name]@hexbear.net
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    8か月前

    is D two single quotes, or one double quote?

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      ·
      8か月前

      I’m guessing single quotes, since a single double quote isn’t valid syntax.

      • MyNameIsRichard@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        8か月前

        Yeah, not even JavaScript is that insane!

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 42 users / day
  • 1.08K users / week
  • 2.23K users / month
  • 6.92K users / 6 months
  • 439 local subscribers
  • 39.9K subscribers
  • 1.96K Posts
  • 40.4K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org