Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Which of these javascript expressions is false?

Which of these javascript expressions is false?

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
8 Posts 4 Posters 2 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cm0002@lemmy.worldC This user is from outside of this forum
    cm0002@lemmy.worldC This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1
    This post did not contain any content.
    powermaker450@discuss.tchncs.deP 1 Reply Last reply
    2
    • cm0002@lemmy.worldC [email protected]
      This post did not contain any content.
      powermaker450@discuss.tchncs.deP This user is from outside of this forum
      powermaker450@discuss.tchncs.deP This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      C, because yes.

      V 1 Reply Last reply
      0
      • powermaker450@discuss.tchncs.deP [email protected]

        C, because yes.

        V This user is from outside of this forum
        V This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        I'd say C too because that's the only one that would be True in a normal programming language and this is javascript so...

        remavas@programming.devR powermaker450@discuss.tchncs.deP 2 Replies Last reply
        0
        • V [email protected]

          I'd say C too because that's the only one that would be True in a normal programming language and this is javascript so...

          remavas@programming.devR This user is from outside of this forum
          remavas@programming.devR This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          It's not true in a normal programming language. If it is true in yours, you should stop using it immediately.

          V 1 Reply Last reply
          0
          • V [email protected]

            I'd say C too because that's the only one that would be True in a normal programming language and this is javascript so...

            powermaker450@discuss.tchncs.deP This user is from outside of this forum
            powermaker450@discuss.tchncs.deP This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            probably not true in most other langauges. although I'm not well versed in the way numbers are represented in code and what makes a number "NaN", something tells me the technical implications of that would be quite bad in a production environment.

            the definitive way to check for NaN in JS would probably be something like

            // with `num` being an unknown value
            
            // Convert value to a number
            const res = Number(num);
            
            /*
             * First check if the number is 0, since 0 is a falsy
             * value in JS, and if it isn't, `NaN` is the only other
             * falsy number value
             */
            const isNaN = res !== 0 && !res;
            
            remavas@programming.devR 1 Reply Last reply
            1
            • remavas@programming.devR [email protected]

              It's not true in a normal programming language. If it is true in yours, you should stop using it immediately.

              V This user is from outside of this forum
              V This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              A non type should be a type. It should be of the type none. And it is in good script languages like Python so I don't know why you think it shouldn't.

              remavas@programming.devR 1 Reply Last reply
              0
              • V [email protected]

                A non type should be a type. It should be of the type none. And it is in good script languages like Python so I don't know why you think it shouldn't.

                remavas@programming.devR This user is from outside of this forum
                remavas@programming.devR This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                They say a picture is worth a thousand words.

                1 Reply Last reply
                0
                • powermaker450@discuss.tchncs.deP [email protected]

                  probably not true in most other langauges. although I'm not well versed in the way numbers are represented in code and what makes a number "NaN", something tells me the technical implications of that would be quite bad in a production environment.

                  the definitive way to check for NaN in JS would probably be something like

                  // with `num` being an unknown value
                  
                  // Convert value to a number
                  const res = Number(num);
                  
                  /*
                   * First check if the number is 0, since 0 is a falsy
                   * value in JS, and if it isn't, `NaN` is the only other
                   * falsy number value
                   */
                  const isNaN = res !== 0 && !res;
                  
                  remavas@programming.devR This user is from outside of this forum
                  remavas@programming.devR This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  NaN is a special floating point value. https://en.wikipedia.org/wiki/IEEE_754

                  It's weird but it makes sense why it was chosen to be this way.

                  1 Reply Last reply
                  1
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups