Nyx's lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 2 days ago

Which of these javascript expressions is false?

lemmy.ml

message-square
15
link
fedilink
69

Which of these javascript expressions is false?

lemmy.ml

☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 2 days ago
message-square
15
link
fedilink
alert-triangle
You must log in or register to comment.
  • davel@lemmy.ml
    link
    fedilink
    English
    arrow-up
    29
    ·
    2 days ago

    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
      20
      ·
      2 days ago

      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
        ·
        1 day ago

        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
        3
        ·
        1 day ago

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

  • twice_hatch@midwest.social
    link
    fedilink
    English
    arrow-up
    2
    ·
    24 hours ago

    Moot! Those ALL fail code review!

  • ThotDragon@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    6
    ·
    2 days ago

    I’m guessing C

    • CapriciousDay@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 day ago

      Just because it’s not a number, doesn’t mean it’s the same not number. But what if it is? 🙃

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      2 days ago

      yup

  • TFed 🍉🌻@infosec.exchange
    link
    fedilink
    arrow-up
    3
    ·
    1 day ago

    @yogthos i afraid of (0 == ‘’) :blob_grinning_sweat:

  • lowleveldata@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    1 day ago

    A && B && C && D

  • ClathrateG [none/use name]@hexbear.net
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    1 day ago

    is D two single quotes, or one double quote?

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      ·
      1 day ago

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

      • MyNameIsRichard@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        1 day ago

        Yeah, not even JavaScript is that insane!

  • salmoura@lemmy.eco.br
    link
    fedilink
    arrow-up
    3
    ·
    2 days ago

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

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      2 days ago

      it’s not B

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.

  • 65 users / day
  • 1.81K users / week
  • 1.82K users / month
  • 1.83K users / 6 months
  • 1 local subscriber
  • 35.7K subscribers
  • 84 Posts
  • 195 Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • BE: 0.19.11
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org