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 [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
                        • supervisor194@lemmy.worldS [email protected]

                          It's not that hard to understand what it is doing and why the decision was made to make it do that. JavaScript has a particular purpose and it's mission is not consistency.

                          It's not like TypeScript doesn't exist if you just get lightheaded at the idea of learning JavaScript's quirks and mastering using it despite them.

                          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]
                          #49

                          Scanned the article: neither mission, nor purpose, nor type coercion unga-bunga explained. Or was I expected to see the greatness of the language and be humbled by its glory and might?

                          supervisor194@lemmy.worldS 1 Reply Last reply
                          1
                          • R [email protected]

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

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

                            Especially that + and - act differently. If + does string concattenation, - should also do some string action or throw an error in this situation.

                            F R 2 Replies Last reply
                            5
                            • S [email protected]

                              Especially that + and - act differently. If + does string concattenation, - should also do some string action or throw an error in this situation.

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

                              That's the case in many languages, pretty much in all that don't have a separate string concatenation operator.

                              S 1 Reply Last reply
                              1
                              • 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?

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

                                It should just randomly pick any "1". Add a bit of spice, you know

                                1 Reply Last reply
                                1
                                • S [email protected]

                                  Scanned the article: neither mission, nor purpose, nor type coercion unga-bunga explained. Or was I expected to see the greatness of the language and be humbled by its glory and might?

                                  supervisor194@lemmy.worldS This user is from outside of this forum
                                  supervisor194@lemmy.worldS This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #53

                                  Well then, rage against the machine for the next 30 years and see if they kill it in favor of a nice, strict language that everybody loves. Maybe you could suggest one here for consideration.

                                  S 1 Reply Last reply
                                  0
                                  • P [email protected]

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

                                    Why would you need an entirely different way of concatenating strings? "11" + 1 -> exception. "11" + to_string(1) = "111"

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

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

                                      I mean, in both cases it's because the LLM and interpreter do things you wouldn't expect.

                                      1 Reply Last reply
                                      2
                                      • 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 [email protected]
                                        #56

                                        This is my favorite language: GHC Haskell

                                        GHC Haskell:

                                        GHCi> length (2, "foo")
                                        1
                                        
                                        Y 1 Reply Last reply
                                        8
                                        • S [email protected]

                                          Especially that + and - act differently. If + does string concattenation, - should also do some string action or throw an error in this situation.

                                          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
                                          #57
                                          • should also do some string action

                                          Like what kind of string action?

                                          "Hello" + " world" is what everyone can understand. Switch with "-" and it becomes pointless.

                                          pupbiru@aussie.zoneP 1 Reply Last reply
                                          3
                                          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