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.
  • __nobodynowhere@sh.itjust.works_ [email protected]

    The one at the end. Subtraction is the opposite of addition. If addition adds a character to the end of the string, it must follow that subtraction would remove a character from the end of the string.

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

    This is how we end up with an endian schism

    1 Reply 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.

      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
      #30

      There's also Chefkoch and Mozart for that purpose.

      1 Reply Last reply
      0
      • G [email protected]

        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 This user is from outside of this forum
        A This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #31

        I mean, I'd never try to do this anyway because if the types aren't the same unexpected things can happen. That's like programming 101.

        G 1 Reply Last reply
        3
        • whaleross@lemmy.worldW [email protected]

          Now that you mention it, it is a bit funny how Lemmy is hating LLMs as a code generation tool while also hating on the interpreter for their own hand typed code not running.

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

          I seldom use an interpreter.

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

            This is too stupid so I had to check.

            Fuck me.

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

            From all the Javascript quiks this is the least stupid and the most obvious.

            1 Reply Last reply
            22
            • 0 [email protected]

              I seldom use an interpreter.

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

              Then you do not do Javascript, because it is an interpreted language.

              Edit: or Python, or a command line shell, or any CORS, or databases, or... Well idk really what you do use honestly.

              0 1 Reply Last reply
              4
              • cm0002@lemmy.worldC [email protected]
                This post did not contain any content.
                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
                #35

                If you mix types like that, it's your own fault

                R S 2 Replies Last reply
                22
                • A [email protected]

                  I mean, I'd never try to do this anyway because if the types aren't the same unexpected things can happen. That's like programming 101.

                  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
                  #36

                  Exactly, which is why designing the language to allow it is incompetence.

                  1 Reply Last reply
                  7
                  • whaleross@lemmy.worldW [email protected]

                    Then you do not do Javascript, because it is an interpreted language.

                    Edit: or Python, or a command line shell, or any CORS, or databases, or... Well idk really what you do use honestly.

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

                    Then you do not do Javascript, because it is an interpreted language.

                    No shit?! Wow... who would've known...

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

                      Oh we've hit an issue that's solved by another language or we could make another framework

                      1 Reply Last reply
                      0
                      • G [email protected]

                        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?

                        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
                        #39

                        maybe we removed the last n characters

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

                          This is too stupid so I had to check.

                          Fuck me.

                          irelephant@programming.devI This user is from outside of this forum
                          irelephant@programming.devI This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #40

                          pro tip:

                          "ba" + 0/0 + "a"
                          
                          W 1 Reply Last reply
                          14
                          • M [email protected]

                            If you mix types like that, it's your own fault

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

                            BS. A language shouldn't have operators that allow non sensical operations like string concatenation when one operand is not a string.

                            S 3 2 Replies Last reply
                            29
                            • P [email protected]

                              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 This user is from outside of this forum
                              R This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #42

                              Nor would I expect "1312" to equal "1213".. Still that operator with these operands should just throw an exception

                              P 1 Reply Last reply
                              1
                              • G [email protected]

                                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.

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

                                Thanks for saving me the typing.

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

                                  It was never intended to run full applications but only the small business scripts and hobbyist homepage stuff that were the thing in the 90s, across inconsistent browsers that were a jungle of hit and miss behaviour where it was preferred that menus keep working even if the mouse effect was not. Anything of scale was expected to be done in Java. Dynamic web pages did not exist and as anything not static was generated server side into a static html file to be rendered on the client.

                                  Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today. It's not a bad thing that IDE and even compilers and preprocessors try to help you write better code today, but then it simply didn't exist.

                                  JavaScript is from a different time and because it has the hard requirement or backwards compatibility there is no changing it and has not been for thirty years except to add stuff to it.

                                  I think it's just silly to ask the past to keep up with the present. Bad code is not the fault of the language regardless, even though junior devs and even seasoned ones like to think so to protect their ego. I think it is better to accept it, learn from it and roll with it because every single platform and language has their weird quirks anyway.

                                  Signed, old dude that learned programming in 8 bit BASIC and 6502 machine code without an assembler, where code bad enough would freeze your machine that required a cold boot and starting over from your last save that you didn't do.

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

                                  Executing after undefined behavior is arguably worse than terminating with an exception. A terminated script can't leak data or wreak havoc in other ways.

                                  1 Reply Last reply
                                  3
                                  • R [email protected]

                                    Nor would I expect "1312" to equal "1213".. Still that operator with these operands should just throw an exception

                                    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
                                    #45

                                    Given it's JavaScript, which was expressly designed to carry on regardless, I could see an argument for it returning NaN, (or silently doing what Perl does, like I mention in a different comment) but then there'd have to be an entirely different way of concatenating strings.

                                    R 1 Reply Last reply
                                    0
                                    • M [email protected]

                                      If you mix types like that, it's your own fault

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

                                      Lol. In a dynamically typed language? I will do this always, that's why I am using it

                                      exu@feditown.comE 1 Reply Last reply
                                      3
                                      • irelephant@programming.devI [email protected]

                                        pro tip:

                                        "ba" + 0/0 + "a"
                                        
                                        W This user is from outside of this forum
                                        W This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #47

                                        This has got to be baNaNa

                                        C maggiwuerze@feddit.orgM 2 Replies Last reply
                                        21
                                        • S This user is from outside of this forum
                                          S This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by [email protected]
                                          #48

                                          Hear me out:

                                          "11" - 1 = "11" - (-1) = "11" (did not find "-1" in "11)

                                          Or

                                          "11" - 1 = "11" - (-1) = "1" (removed first "1")

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