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. JavaScript

JavaScript

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
152 Posts 83 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.
    K robotzap10000@feddit.nlR P whaleross@lemmy.worldW avidamoeba@lemmy.caA 23 Replies Last reply
    794
    • cm0002@lemmy.worldC [email protected]
      This post did not contain any content.
      K This user is from outside of this forum
      K This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      Lets fix it. I think that since we are removing the ones, then "11" - 1 should be equal to "".

      r00ty@kbin.lifeR 1 Reply Last reply
      3
      • cm0002@lemmy.worldC [email protected]
        This post did not contain any content.
        robotzap10000@feddit.nlR This user is from outside of this forum
        robotzap10000@feddit.nlR This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        [object Object][object Object]

        1 Reply Last reply
        31
        • cm0002@lemmy.worldC [email protected]
          This post did not contain any content.
          P This user is from outside of this forum
          P This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          You have some random QA Testers to thank for that!

          M 1 Reply Last reply
          9
          • cm0002@lemmy.worldC [email protected]
            This post did not contain any content.
            whaleross@lemmy.worldW This user is from outside of this forum
            whaleross@lemmy.worldW This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

            G 0 M 3 Replies Last reply
            33
            • K [email protected]

              Lets fix it. I think that since we are removing the ones, then "11" - 1 should be equal to "".

              r00ty@kbin.lifeR This user is from outside of this forum
              r00ty@kbin.lifeR This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              Should it, or should it be "1"? (just removing one, one)

              G 1 Reply Last reply
              4
              • cm0002@lemmy.worldC [email protected]
                This post did not contain any content.
                avidamoeba@lemmy.caA This user is from outside of this forum
                avidamoeba@lemmy.caA This user is from outside of this forum
                [email protected]
                wrote on last edited by [email protected]
                #7

                This is too stupid so I had to check.

                Fuck me.

                gsus4@mander.xyzG A buboscandiacus@mander.xyzB cidvicious@sh.itjust.worksC J 6 Replies Last reply
                135
                • cm0002@lemmy.worldC [email protected]
                  This post did not contain any content.
                  B This user is from outside of this forum
                  B This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  https://www.destroyallsoftware.com/talks/wat

                  1 Reply Last reply
                  10
                  • avidamoeba@lemmy.caA [email protected]

                    This is too stupid so I had to check.

                    Fuck me.

                    gsus4@mander.xyzG This user is from outside of this forum
                    gsus4@mander.xyzG This user is from outside of this forum
                    [email protected]
                    wrote on last edited by [email protected]
                    #9

                    Hm, playing devil's advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

                    The first is assumed to be a concat because one of the parcels is a string...

                    It's just doing a lot of stuff for you that it shouldn't be in first place 🤭

                    avidamoeba@lemmy.caA 0 D 3 Replies Last reply
                    63
                    • avidamoeba@lemmy.caA [email protected]

                      This is too stupid so I had to check.

                      Fuck me.

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

                      Unfortunately, it makes sense if you know what + means, which is concatenate. - is strictly a math function though.

                      Not saying that makes this better. It just makes sense.

                      T G 2 Replies Last reply
                      12
                      • A [email protected]

                        Unfortunately, it makes sense if you know what + means, which is concatenate. - is strictly a math function though.

                        Not saying that makes this better. It just makes sense.

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

                        It's an issue with most if not all languages that aren't strongly typed.

                        1 Reply Last reply
                        5
                        • P [email protected]

                          You have some random QA Testers to thank for that!

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

                          This is a really good interview, and does a good job highlighting Javascript's biggest strength: it's flexibility.

                          “It was also an incredible rush job, so there were mistakes in it. Something that I think is important about it is that I knew there would be mistakes, and there would be gaps, so I made it very malleable as a language.”

                          He cites the “discovery” of asm.js inside of JavaScript, calling it “another thing I’m particularly proud of in the last 10 years.” It uses the bitwise operators that were included in the original JavaScript which are now the basis for a statically-typed language with machine types for high-speed performance. “If it hadn’t been in there from 1995, it would’ve been hard to add later. And the fact that it was there all along meant we could do incredibly fast JavaScript.”

                          He tells InfoWorld it’s “this very potent seed that was in the original JavaScript from the 10 days of May in 1995.” JavaScript’s 32-bit math operators (known as bitwise operators) trace their lineage all the way back to the C programming language — and to Java. This eventually led to WebAssembly — a way to convert instructions into a quickly-executable binary format for virtual machines — and the realization that with a JavaScript engine, “you can have two languages — the old language I did with the curly braces and the functions and the shift operators, and this new language which is a binary language, not meant for reading by humans or writing. But it can be generated by compilers and tools, and can be read by tools…”

                          1 Reply Last reply
                          6
                          • gsus4@mander.xyzG [email protected]

                            Hm, playing devil's advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

                            The first is assumed to be a concat because one of the parcels is a string...

                            It's just doing a lot of stuff for you that it shouldn't be in first place 🤭

                            avidamoeba@lemmy.caA This user is from outside of this forum
                            avidamoeba@lemmy.caA This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #13

                            Yup. It's completely inconsistent in its interpretation of the + operator.

                            gsus4@mander.xyzG 1 Reply Last reply
                            13
                            • avidamoeba@lemmy.caA [email protected]

                              Yup. It's completely inconsistent in its interpretation of the + operator.

                              gsus4@mander.xyzG This user is from outside of this forum
                              gsus4@mander.xyzG This user is from outside of this forum
                              [email protected]
                              wrote on last edited by [email protected]
                              #14

                              Yeah, I actually had to try 1+"11" to check that it didn't give me 12, but thankfully it commutes it's consistent 😇

                              P 1 Reply Last reply
                              8
                              • avidamoeba@lemmy.caA [email protected]

                                This is too stupid so I had to check.

                                Fuck me.

                                buboscandiacus@mander.xyzB This user is from outside of this forum
                                buboscandiacus@mander.xyzB This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #15

                                Fuck me.

                                1 Reply Last reply
                                1
                                • gsus4@mander.xyzG [email protected]

                                  Yeah, I actually had to try 1+"11" to check that it didn't give me 12, but thankfully it commutes it's consistent 😇

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

                                  it commutes

                                  Maybe the behaviour with regard to type conversion, but not for the operation itself.

                                  "13"+12 and 12+"13" don't yield the same result.

                                  R 1 Reply Last reply
                                  3
                                  • A [email protected]

                                    Unfortunately, it makes sense if you know what + means, which is concatenate. - is strictly a math function though.

                                    Not saying that makes this better. It just makes sense.

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

                                    It is 'comprehensible' in the sense that it's possible to figure out how it happened, but it absolutely does not "make sense" in terms of being a reasonable language design decision. It's 100% incompetence on the part of the person who created Javascript.

                                    A R F 3 Replies Last reply
                                    19
                                    • r00ty@kbin.lifeR [email protected]

                                      Should it, or should it be "1"? (just removing one, one)

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

                                      Which "1" did it remove? And did it search the string to find a "1" to remove, or did it remove whichever character happened to be at array index 1?

                                      __nobodynowhere@sh.itjust.works_ A F 3 Replies Last reply
                                      1
                                      • whaleross@lemmy.worldW [email protected]

                                        People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

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

                                        the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense...

                                        ...itself makes no sense. It is wrong and bad that Javascript was ever designed that way in the first place.

                                        whaleross@lemmy.worldW 1 Reply Last reply
                                        18
                                        • avidamoeba@lemmy.caA [email protected]

                                          This is too stupid so I had to check.

                                          Fuck me.

                                          cidvicious@sh.itjust.worksC This user is from outside of this forum
                                          cidvicious@sh.itjust.worksC This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #20

                                          I think I'm on the side of "if you do this in your code, you deserve what you get."

                                          1 Reply Last reply
                                          8
                                          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