• lastunusedusername2@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    61
    ·
    10 months ago

    It looks like it’s just assigning the scope variable m to true (also false in the m=!1 case.

    It’s minified code and m=!0 is fewer characters than m=true.

  • WIPocket@lemmy.world
    link
    fedilink
    arrow-up
    47
    ·
    10 months ago

    !0 is shorter than true, !1 is shorter than false. You are looking at minified javascript.

  • relevants@feddit.de
    link
    fedilink
    arrow-up
    42
    arrow-down
    1
    ·
    edit-2
    10 months ago

    It’s not code anyone is supposed to read or work with, this is the result of minifying it to be as short as possible. And from a quick glance what’s happening is that a variable is set to correspond with whether the cursor is currently over a certain element. Not sure what’s funny about this?

  • FooBarrington@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    10 months ago

    You can go one step further and use the Bang-Bang operator:

    !!m

    To be read as “Bang! Bang! You’re a boolean now!”

    • alokir@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      10 months ago

      I might be in the minority but I prefer to do it like this: Boolean(m).

      It’s the same thing but less cool. On the flip side it’s easier to read when you have a line full of operators.

      • FooBarrington@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        10 months ago

        Yep, that’s a much better way! It’s like the “goes down to” operator - a neat trick you should never use :)

        while (i --> 0) { ... }