There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

lemmy.ml

420stalin69 , to programmerhumor in the hardest exam question
  1. Duck typing
  2. Typescript
Fargeol , to programmerhumor in the hardest exam question

1 - Easiest way to run a script in your browser
2 - Always finds its way if inputs are bad
Nan - undefined

Skullgrid ,
@Skullgrid@lemmy.world avatar

NaN is of type number. because fuck me.

zea_64 ,

IEEE-754

kevincox ,
@kevincox@lemmy.ml avatar

To be fair, this is actually reasonable. But it does look stupid on the face of it.

joneskind ,
@joneskind@lemmy.world avatar

When my console throws a NaN I kinda think of it as an Halloween kid receiving a fruit instead of a candy. They won’t say “That’s a fruit”. They’ll say “That’s not a treat”.

I’m personally pissed more often by a falsy 0.

Did you know that early analog computers would literally explode when asked to divide by 0?

Now computers just say “Hey stupid, that shit is not even a Number in a mathematical sense, but sure I’ll add one to it.” instead of “Why would you kill me like this?”

You can’t really define Infinity as a number, yet it is part of their world.

So typeof NaN === ‘number’ totally makes sense in that regard.

If you ever worked with arrays of dates, don’t judge NaN too harshly.

Skullgrid ,
@Skullgrid@lemmy.world avatar

Falsy zero? What’s wrong with that, 1 is true and 0 is false. I thought that was standard logic?

joneskind ,
@joneskind@lemmy.world avatar

in javascript a property is truthy if it exists


<span style="color:#323232;">myThing.property = "some string"
</span><span style="color:#323232;">
</span><span style="color:#323232;">if (myThing.property) { // true
</span><span style="color:#323232;">  // do something
</span><span style="color:#323232;">}
</span>

It works with everything except of course for falsy values


<span style="color:#323232;">myThing.number = someNumberThatShouldNotBeEqualToZero
</span><span style="color:#323232;">
</span><span style="color:#323232;">if (myThing.number) {
</span><span style="color:#323232;">  // do something very important with that number that should not be equal to zero
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">// This can fail at anytime without warning
</span>

So you’ve got to be extra careful with that logic when you’re dealing with numbers.

I am not saying it’s wrong though. I’m saying it’s often annoying.

Skullgrid ,
@Skullgrid@lemmy.world avatar

ah ok , I think I write this a bit more verbose when using other languages, instead of


<span style="color:#323232;">if(thing)
</span><span style="color:#323232;">{
</span><span style="color:#323232;">   stuff;
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span>

I do


<span style="color:#323232;">
</span><span style="color:#323232;">if(thing != null)
</span><span style="color:#323232;">{
</span><span style="color:#323232;">   stuff;
</span><span style="color:#323232;">}
</span>

so checking for numbers being truthy & existing didn’t seem like an issue

joneskind , (edited )
@joneskind@lemmy.world avatar

In the case of a non-existing property, the value would be undefined rather than null.

And while == and != exist in JavaScript, most linters will throw an error and require a === and !== instead as they should be avoided.


<span style="color:#323232;">null == undefined // true
</span><span style="color:#323232;">null === undefined // false
</span>

Besides, null is a perfectly valid value for a property, just as 0. Working with API Platform, I couldn’t tell the number of times I used this kind of statement:


<span style="color:#323232;">if (property || property === null) {
</span><span style="color:#323232;">  // do some stuff
</span><span style="color:#323232;">}
</span>

Probably just as much as


<span style="color:#323232;">if (property || property === 0) {
</span><span style="color:#323232;">  // do some stuff
</span><span style="color:#323232;">}
</span>
space ,

Easiest? More like… The only way.

udon , to programmerhumor in the hardest exam question
  1. it’s easy to make fun of
  2. it makes every other programming language look better in comparison
DestroyMegacorps , to memes in Why you should buy Toyota

my family had a toyota for like 30 years still works to this day and the best part it gets little maintenance

AFC1886VCC ,

Toyotas are everything-proof!

sincle354 , to programmerhumor in the hardest exam question

We have forced it, quite hamfistedly, to do anything. The organic hell-evolution of web browsers turned them into do-anything sandboxed mini-OS. It meant whatever hellish code you used to write your corporate mandated web app could now become a perfectly bloated standalone application. And the demonic language that would enable it was called Javascript. It does the backend and it does the frontend. You could consider those advantages over other devices, like toasters and those handheld electronic games from the 80s.

xmunk , to programmerhumor in the hardest exam question
  1. Ajax.
  2. Uhhh…
Technus , to memes in shrooms?

Even some of the ones that are edible still secretly want to kill you. From the Wikipedia entry for “chicken of the woods”:

In some cases eating the mushroom "causes mild reactions … for example, “swollen lips” or in rare cases “nausea, vomiting, dizziness and disorientation” to those who are sensitive. This is believed to be due to a number of factors that include allergies to the mushroom’s protein or toxins which are only somewhat stable at high temperatures.

I’ll eat portabellos if they come on pasta or pizza (though I’ve started taking them off the latter because they turn to rubber in the microwave) but I sure as hell am not going out of my way to order any dish that features them (mushrooms) as the main protein.

groet ,

pizza

microwave

I don’t think the mushrooms are the problem in that situation

Technus ,

Bite me, I don’t have the counter space for a toaster oven and I’m not heating up the actual oven every time I want a leftover slice.

If the pizza is made from quality ingredients to begin with, it survives microwaving decently well. Mushrooms just refuse to play ball.

notabot ,

If you have a stove I can definitely recommend heating your pizza in a dry (with no oil) frying pan. Set the temperature medium-low and heat a slice or two at a time for a few minutes. It comes out like it was freshly cooked.

ByteJunk ,
@ByteJunk@lemmy.world avatar

This is why the internet is worth saving.

notabot ,

Thanks, that rather made my day.

EmoDuck ,
LinkOpensChest_wav ,
@LinkOpensChest_wav@lemmy.blahaj.zone avatar

I learned this hack shortly before being diagnosed with celiac and lactose intolerance haha, after a lifetime of eating cold slices

I can confirm it works well, though

notabot ,

Oof, that sucks. It seems like the universe really does enjoy a cruel prank sometimes. I hope you’ve found something equally enjoyable to fill the pizza shaped hole in your meals.

LinkOpensChest_wav ,
@LinkOpensChest_wav@lemmy.blahaj.zone avatar

I did, thanks! I just eat tacos and stuff when I need my comfort food fix

Tar_alcaran ,

Veggie crusts are actually pretty good nowadays. Unfortunately, lactose-free cheese is not.

But aren’t parmesan and Gouda very low in lactose, because they can be quite old?

Technus ,

I finally got around to trying this. I don’t see the point. By the time the cheese was re-melted, the crust turned into a hard cracker and it took ten times longer than the microwave. It’s quite possible I had the stove up too high (it’s an electric stove and I had it on 4/10), but I’d still say the point goes to the microwave for being quicker and having greater margin for error.

notabot ,

Hmmm, it’s hard to debug pizza remotely, but maybe the heat wasn’t high enough, it normally only takes a minute or two to heat through and cooking it for longer probably would make the base go hard.

Thanks for reporting bavk though, and I’m sorry you had a suboptimal pizza result.

EmoDuck ,

I hope you’ll soon get the help you need 🙏

gimpchrist ,
@gimpchrist@lemmy.world avatar

If the pizza is made from real quality ingredients to begin with you should be comfortable with eating it cold judgement eyes

systemglitch ,

I think it’s perfect part cold and part warm… Best of both worlds.

systemglitch ,

Here’s a hint for you. Lower the power of the microwave to 4/10 and cook about 50% longer. Once you get the timing down you leftover pizza will be much better and less rubbery.

Most people are clueless about how to properly use a microwave, because no one teaches us, but max all the time is not how it should be used.

Technus ,

That’s effectively what I do, I don’t just blast it for a minute and a half.

I normally don’t futz with the power settings but I’ll do 30s at a time and check if it’s heated, then move it around so the hotspots in the microwave hit different parts of it (the turntable only does so much).

candybrie ,

Some people also get mild to severe reactions to pizza. They’re sensitive to night shade. Or lactose intolerant. Or have celiac’s. Or are allergic to one of the toppings.

EmoDuck ,

Said people are weak and should be removed from the gene pool

systemglitch ,

Says the guy who has to unspin himself after walking up stairs.

bjoern_tantau , to memes in shrooms?
@bjoern_tantau@swg-empire.de avatar

Many refugees from Syria got poisoned by mushrooms because a common edible Syrian mushroom looks very much like a poisonous German mushroom.

MoonMelon , (edited )

Happens to some SE Asians in North America too, because the edible straw mushroom from SE Asia resembles one here called “death cap”. Amanita phalloides. What’s fucked up is right before it kills you your symptoms actually improve, so people get discharged from the hospital and think they are going to be ok. I forage mushrooms but I stay away from white gilled mushrooms completely.

argentcorvid ,
@argentcorvid@midwest.social avatar

Yeah I had my yard full of destroying angels last summer, when they first showed up I was all “sweet! Mushrooms!” Because they look real similar to agaricus. But then I saw the white gills, and was all :(.

And I made sure to tell my kids not to mess with them and why.

Grass ,

I never thought about this being possible and now I can’t help but laugh at how deceptive nature is.

Norgur , to programmerhumor in the hardest exam question

You can make your speakers go BRRRRRRRRR via Home Assistant with it

Tja ,

Elaborate?

gaael , to programmerhumor in the hardest exam question

You’ll find an npm package to help you count up to 2.

(I recently learned - maybe here - that the is-even package has over 170k weekly downloads)

Drusenija ,

What’s even wilder is if you look at the code of that package, all it does is include the is-odd package and then return !is. And the is-odd package isn’t much better, it does some basic checks on the input and then returns n % 2 === 1.

NotAViciousCyborg ,

I thought I was missing something. JS is one of my main languages and I always just write the is-odd function myself since it’s like 10 characters. It boggles the mind that is-even has 176k weekly downloads

Aqarius ,

If youre lazy/busy enough, doing basic checks on the input is enough boilerplate to package out.

gaael ,

Also there are 40-something packages depending on it, so I guess it gets pulled automatically when they are used.

kevincox ,
@kevincox@lemmy.ml avatar

To be fair having a name can make things easier to read. I get that i % 2 == 0 is a common pattern and most programmers will quickly recognize what is happening. But isEven(i) is just that much easier to grok and leaves that brainpower to work on something else.

But I would never import a package for it. I would just create a local helper for something this trivial.

NotAViciousCyborg ,

Exactly what I would do if I had to reuse it, especially now since I know that adding a package would actually add 2. It all just seems so…inefficient

kevincox ,
@kevincox@lemmy.ml avatar

Even if the code isn’t reused adding names to sub-expressions can be very valuable. Often times I introduce new functions or variables even if they are only used once so that I can give them a descriptive name which helps the reader more quickly understand what is happening.

NotAViciousCyborg ,

Yeah, I do that with pretty much every separate operation in c# since our solutions are pretty big. Most of my JS scripts are just done in ServiceNow which are separated and named appropriately.

gravitas_deficiency ,

I’ve always looked at stuff like that as much more along the lines of performance art than anything else.

hemko ,

Is-even continues to be the best joke in the industry

kamen ,

This must be a “hold my beer” kind of joke and someone wanting to see how far they can take it.

PrettyFlyForAFatGuy ,
NaibofTabr , (edited ) to memes in shrooms?

Don’t use mushroom ID apps and don’t trust random guidebooks from Amazon, they’re probably AI-generated crap.

The deadly mycotoxin orellanine, which is present in Cortinarius rubellus, the deadly webcap, may not cause symptoms in those who ingested the mushroom until one or two weeks have passed – after detectable traces of the toxin are already gone, and late-stage kidney failure has already begun. Connecting the sickness with certainty to a misidentified wild mushroom that was eaten weeks earlier with no obvious ill effects is not always possible.

Yeah, nope.

felbane ,

This is basically vegan rabies

SGG , to programmerhumor in the hardest exam question
  1. It runs in browsers
  2. If you hate your co-workers, then they will also feel your pain.
bloubz , to programmerhumor in the hardest exam question

JIT compilation

heavyboots , to programmerhumor in the hardest exam question
@heavyboots@lemmy.ml avatar

Browsers love it!

Practically anything you write will execute without all that scope and well formed statements nonsense.

Mind you, number 2 is also its biggest flaw as well, but…

jordanlund , to programmerhumor in the hardest exam question
@jordanlund@lemmy.world avatar

Over what?

wewbull ,

Death by wasps

Buffalo1387 ,

Can I please pick the wasps?

wewbull ,

Totally understandable choice.

gimpchrist ,
@gimpchrist@lemmy.world avatar

Did a robot just ask to die because of JavaScript hahaha

Buffalo1387 ,

The bot toggle was on for my account for some reason but I am human… I think

It should be off now

gimpchrist ,
@gimpchrist@lemmy.world avatar

ROFL it is not

56_ ,
@56_@lemmy.ml avatar

It seems it doesn’t propagate to other servers immediately though.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • lifeLocal
  • goranko
  • All magazines