FediTown
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
JPDev@programming.dev to Programmer Humor@programming.dev · 1 year ago

===

programming.dev

message-square
49
link
fedilink
3

===

programming.dev

JPDev@programming.dev to Programmer Humor@programming.dev · 1 year ago
message-square
49
link
fedilink
alert-triangle
You must log in or # to comment.
  • Buttons@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    https://programming.dev/post/7789832

    • BaardFigur@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      How does people manage to work with that language?

      • schnurrito@discuss.tchncs.de
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        by not ever using == and !=, but only === and !==

      • darcy@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        almost forced to for web front end. why you would use it anywhere else, however, i will never know

        • Turun@feddit.de
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          The same reason people drive their car to buy groceries.

          You bought it for something where it was the only option, driving 30km to work everyday. But ever since you got it, the trip to the super market is kinda too hot in the summer and too cold in the winter and what if you spontaneously need to buy more than expected?

          People learn it for front end dev, and then they use what they know for back end too.

      • FooBarrington@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Typescript :)

      • JaddedFauceet@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        By banishing the bad part of the language with linter.

        For instance, standard eslint preset has rules that enforce usage of ===, https://eslint.org/docs/latest/rules/eqeqeq

        These rules often come with project starter template

        • fidodo@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          And typescript is basically just a linter on steroids

  • jenny_ball@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    it depends on what your definition of is is

  • GiM@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    parseInt(0.00000000005)

    5

  • luciole (he/him)@beehaw.org
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    I wish the assignment operator wasn’t the equal sign.

    • cerement@slrpnk.net
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      :=

      • MxM111@kbin.social
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        That’s delayed assignment.

        • cerement@slrpnk.net
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          procrastination assignment

    • QuazarOmega@lemy.lol
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago
      x 👈 5
      
      • xedrak@kbin.social
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Ok deal, but that means we need to change the equality operator to 👉👈

        • OpenStars@startrek.website
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          You sonnofabitch I’m in!:-P

      • OpenStars@startrek.website
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 year ago
        x 🔫 5
        

        the pew pew principle /s

        • Malgas@beehaw.org
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          Interpreter: Wait, x is 5?

          This code: Always has been.

          • OpenStars@startrek.website
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            It is now, if you know what’s good for you.

  • Lunya \ she/it@iusearchlinux.fyi
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    I still don’t understand the === operator

    • Limitless_screaming@kbin.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      == but for JavaScript. What you don’t understand is the == of JavaScript.

    • frezik@midwest.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      The short answer is that your language needs === when it fucked up the semantics of ==, but it’s also too popular and you can’t fix it without breaking half the web.

    • Mikina@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      It’s also important if you’re checking hashes (at least, it was - if you’re using correct hashing algorithm that isn’t ancient, you will not have this problem).

      Because if you take for example “0e462097431906509019562988736854” (which is md5(“240610708”), but also applicable to most other hashing algorithms that hash to a hex string), if(“0e462097431906509019562988736854” == 0) is true. So any other data that hashes to any variantion of “0e[1-9]+” will pass the check, for example:

      md5("240610708") == md5("hashcatqlffzszeRcrt")

      that equals to

      "0e462097431906509019562988736854" == "0e242700999142460696437005736231"

      which thanks to scientific notation and no strict type checking can also mean

      0462097431906509019562988736854 == 0242700999142460696437005736231

      which is

      0 == 0 `

      I did use md5 as an example because the strings are pretty short, but it’s applicable to a whole lot of other hashes. And the problem is that if you use one of the strings that hash to a magic hash in a vulnerable site, it will pass the password check for any user who’s password also hashes to a magic hash. There’s not really a high chance of that happening, but there’s still a lot of hashes that do hash to it.

      • darcy@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        that is terrifying

    • BougieBirdie@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      The other comments explains it in pretty good detail, but when I was learning my teacher explained it sort of like a mnemonic.

      1 + 1 = 2 is read “one plus one equals two”

      1 + 1 == 2 is read “one plus one is equal to two”

      1 + 1 === 2 is read “one plus one is really equal to two”

      And you hit the nail on the head, is that === is type explicit while == is implicit.

      • bobbykjack@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        1 year ago

        I’d use something like:

        = becomes

        == equals

        === is identical to

        It’s funny how everyone thinks “equals” in this context should be “identical to” when, in normal language, it doesn’t really mean that at all!

    • kevincox@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      JS’s == has some gotchas and you almost never want to use it. So === is what == should have been.

      All examples are true:

      "1" == true
      [1, 2] == "1,2" 
      " " == false
      null == undefined 
      

      It isn’t that insane. But some invariants that you may expect don’t hold.

      "" == 0
      "0" == 0
      "" != "0" 
      
    • clb92@feddit.dk
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      1 year ago

      Like == but more strict. The == operator will do type conversion, so 0 == '' will actually be true, as an example. Sometimes (honestly, most times) you may want to compare more strictly.

      See this StackOverflow answer: https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons

    • QuazarOmega@lemy.lol
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago
      > 1 == 1
      true
      > 1 == '1'
      true
      > 1 === '1'
      false
      

      (from node REPL)

      Basically it’s the real equals sign perfection

    • SzethFriendOfNimi@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      So in JavaScript there’s the assignment

      =
      

      and the comparator is

      ==
      

      Since there’s no types JS will do implicit conversion before comparison when using == in a case like this

      if(false == '0'){
          //this is true
      }
      

      But with === it doesn’t. It means literally compare these

      if(false === '0'){
          //this is false
      }else{
          //so this will execute instead 
      }
      

      But this, however, will

      var someState = false;
       if(someState === false){
          //this is true
      }
      
      • runswithjedi@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Best answer. Thanks Lemmyoverflow.

        • idunnololz@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          Np. closed as duplicate

    • SmoothIsFast@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      It’s like the ==, but there’s one more =

  • I Cast Fist@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    Don’t forget that _.isFinite('1') returns true ;)

  • tiredofsametab@kbin.social
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    1 + false ? (I have no idea in which order JS would evaluate things as I rarely have to touch that language much anymore)

  • cally [he/they]@pawb.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    1+1====2! ← dreamberd developer

    • gandalf_der_12te@feddit.de
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Basically Java in a nutshell

  • DrunkenPirate@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    ChatGpt: 1+1≈2

    • OpenStars@startrek.website
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      Reddit: 1+1=your muther (sic, x2)

      X: 1+1≈we should violently overthrow the government

      4chan: nvm, I don’t want to get banned for saying this one

      • Darkaga@kbin.social
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        4chan: “Gamer words”

        • OpenStars@startrek.website
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          No, that’s Discord 🙃

  • Blackmist@feddit.uk
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    JS devs should have a font that turns == into ≈.

  • majestic@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    As a backend developer i still dont know a shit what that means

    • UndercoverUlrikHD@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      In javascript, === does not perform type coercion when checking for equality

    • blackn1ght@feddit.uk
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Because in JS:

      1 == "1" // true
      1 === "1" // false
      
  • xedrak@kbin.social
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    cries in PHP

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      I also came to represent my php breathren.

  • Tyfon@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    I’m JavaScript developer. I love coding WebApps. JS sucks💩.

Programmer Humor@programming.dev

programmer_humor@programming.dev

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: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 2K users / day
  • 3.93K users / week
  • 7.93K users / month
  • 19.9K users / 6 months
  • 1 local subscriber
  • 25K subscribers
  • 1.49K Posts
  • 45.2K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.12
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org