programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
cm0002@lemmy.world to Programmer Humor · 1 day ago

Which of these javascript expressions is false?

lemmy.ml

message-square
68
link
fedilink
  • cross-posted to:
  • [email protected]
405

Which of these javascript expressions is false?

lemmy.ml

cm0002@lemmy.world to Programmer Humor · 1 day ago
message-square
68
link
fedilink
  • cross-posted to:
  • [email protected]
  • jenesaisquoi@feddit.org
    link
    fedilink
    English
    arrow-up
    54
    arrow-down
    1
    ·
    1 day ago

    It’s C

    • MajesticElevator@lemmy.zip
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      6 hours ago

      Wtf? Min > Max???

      • Pup Biru@aussie.zone
        link
        fedilink
        English
        arrow-up
        9
        ·
        edit-2
        6 hours ago

        Math.min isn’t the minimum integer; it’s the minimum of a list (and max visa versa)… the min/max of an undefined list is the same… IDK what it is, but this probably the most reasonable of the “WTFs” they could have put there i think… other languages would throw an exception or not compile (which JS definitely SHOULD do instead of this, buuuuut lots of JS has aversions to errors)

        *edit: okay the curiosity was killing me: Math.min() is Infinity and Math.max() is -Infinity

        • MajesticElevator@lemmy.zip
          link
          fedilink
          arrow-up
          3
          ·
          6 hours ago

          That explains it then. It could be mislead for -inf and +inf

    • PrettyFlyForAFatGuy@feddit.uk
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      11 hours ago

      yep, because it’s two different instances of an object

      • Log in | Sign up@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        3 hours ago

        I always thought that NaN is required by IEEE rules to never equal any other number, including itself, because you can make NaN in different ways and this shouldn’t result in equality or something, so C is wild but not javascript’s fault.

        The other three being true is definitely javascript’s insane fault, though.

    • JCpac@lemmy.today
      link
      fedilink
      English
      arrow-up
      91
      ·
      21 hours ago

      No, it’s Javascript, keep up

      • FanBlade@lemmynsfw.com
        link
        fedilink
        English
        arrow-up
        42
        arrow-down
        1
        ·
        21 hours ago

      • ChickenLadyLovesLife@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        13 hours ago

        Javascript is basically just C with some syntactical sugar, right? RIGHT?!?

        • kryptonianCodeMonkey@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          4 hours ago

          Say when…

Programmer Humor

programmer_humor

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: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 2.84K users / day
  • 4.91K users / week
  • 8.35K users / month
  • 18.1K users / 6 months
  • 2.4K local subscribers
  • 23.3K subscribers
  • 1.39K Posts
  • 52.3K Comments
  • Modlog
  • mods:
  • adr1an
  • Feyter
  • BurningTurtle
  • Pierre-Yves Lapersonne
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org