eviltoast
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
hydroptic@sopuli.xyz to Programmer Humor@lemmy.ml · 2 years ago

"☹️".reverse() == "🙂"

sopuli.xyz

message-square
25
link
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
19

"☹️".reverse() == "🙂"

sopuli.xyz

hydroptic@sopuli.xyz to Programmer Humor@lemmy.ml · 2 years ago
message-square
25
link
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
alert-triangle
You must log in or # to comment.
  • lelgenio@lemmy.ml
    link
    fedilink
    arrow-up
    11
    ·
    2 years ago
    [🌽].pop() == 🍿
    
    • tetris11@lemmy.ml
      link
      fedilink
      arrow-up
      8
      ·
      edit-2
      2 years ago
      "🚴".push() = "🚲🤸"
      
  • deathmetal27@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    2 years ago

    “:-)”.reverse() == “)-:”

    Close enough

  • BaumGeist@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    deleted by creator

    • Boomkop3@reddthat.com
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      wasn’t it
      🙁
      .
      r
      e
      v
      e
      r
      s
      e
      ()

      • Rain World: Slugcat Game@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 years ago

        "
        🙂
        "
        .
        r
        e
        v
        e
        r
        s
        e
        (
        )
        =
        "
        🙃
        "

      • Rain World: Slugcat Game@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 years ago

        deleted by creator

    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      You’re no fun

  • 418teapot@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 years ago

    Best I can do is

    "\ude41🙂".split("").reverse().join("")
    

    returns "\ude42🙁"

  • RiceMunk@sopuli.xyz
    link
    fedilink
    arrow-up
    3
    ·
    2 years ago

    but

    "🙂".reverse() == "🙃"

  • socsa@piefed.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    Be the operator overload you wish to see in the world

  • tetris11@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    2 years ago
    "🐈".concat() = "😼"
    
  • MultipleAnimals@sopuli.xyz
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    JavaScript taking notes

  • AllNewTypeFace@leminal.space
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    Then “b” backwards would have to be “d”

    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      5
      ·
      2 years ago

      "E".reverse() == "∃"

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 years ago

    deleted by creator

  • Boomkop3@reddthat.com
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    You could implement that on a chat, but I wouldn’t do that on a string

    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      Where’s your sense of adventure?!

  • CanadaPlus@lemmy.sdf.org
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    Also, it should turn an error into an empty but successful call. /s

    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      Calling reverse() on a function should return its inverse

      • tetris11@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        2 years ago
        isprime.reverse(True)
        // outputs 19 billion prime numbers. Checkmate, atheists.
        
  • TCB13@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 years ago

    Today I found out that this is valid JS:

    const someString = "test string";
    console.log(someString.toString());
    
    • Skull giver@popplesburger.hilciferous.nl
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      2 years ago

      [This comment has been deleted by an automated system]

      • hydroptic@sopuli.xyzOP
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        I dint know many OO languages that don’t have a useless toString on string types.

        Well, that’s just going to be one of those “it is what it is” things in an OO language if your base class has a toString()-equivalent. Sure, it’s probably useless for a string, but if everything’s an object and inherits from some top-level Object class with a toString() method, then you’re going to get a toString() method in strings too. You’re going to get a toString() in everything; in JS even functions have a toString() (the output of which depends on the implementation):

        In a dynamically typed language, if you know that everything can be turned into a string with toString() (or the like), then you can just call that method on any value you have and not have to worry about whether it’ll hurl at runtime because eg. Strings don’t have a toString because it’d technically be useless.

        • Skull giver@popplesburger.hilciferous.nl
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          2 years ago

          [This comment has been deleted by an automated system]

      • TCB13@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 years ago

        I dint know many OO languages that don’t have a useless toString on string types

        Okay, fair enough. Guess I never found about it because I never had to do it… JS also allows for "test string".toString() directly, not sure how it goes in other languages.

        • tmat256@lemmings.world
          link
          fedilink
          arrow-up
          1
          ·
          2 years ago

          It’s also incredibly useful as a failsafe in a helper method where you need the argument to be a string but someone might pass in something that is sort of a string. Lets you be a little more flexible in how your method gets called

        • Skull giver@popplesburger.hilciferous.nl
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          2 years ago

          [This comment has been deleted by an automated system]

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

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: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

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

  • 8 users / day
  • 798 users / week
  • 1.37K users / month
  • 5.05K users / 6 months
  • 26 local subscribers
  • 42.7K subscribers
  • 1.98K Posts
  • 32.2K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.17
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org