Right now … You’re looking at my comment

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.

📛Maven
link
fedilink
English
111Y

Well I hate that. Is there a reason m=1 wouldn’t be the same thing as m=!0?

1 != true, 1 is an int, true is a boolean

@master5o1@lemmy.nz
link
fedilink
English
11Y

deleted by creator

1 is truthy, but not the exact same thing as true, and the distinction can be important.

@Hack3900@lemdit.com
link
fedilink
English
391Y

Types are dynamic so I think the ! operator converts int to bool in JS

A blurry chunk of screenshot that someone bled on, that’s what.

@relevants@feddit.de
link
fedilink
41
edit-2
1Y

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?

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

!!m

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

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.

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) { ... }

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

Create a post

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.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.5K Comments
  • Modlog