708
top 50 comments
sorted by: hot top controversial new old
[-] gaael@lemmy.world 94 points 6 months ago

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@lemmy.world 81 points 6 months ago

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-odd. And the is-odd package isn't much better, it does some basic checks on the input and then returns n % 2 === 1.

[-] NotAViciousCyborg@lemmy.world 26 points 6 months ago

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

[-] kevincox@lemmy.ml 19 points 6 months ago

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@lemmy.world 10 points 6 months ago

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@lemmy.ml 11 points 6 months ago

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.

load more comments (1 replies)
load more comments (2 replies)
load more comments (1 replies)
[-] PrettyFlyForAFatGuy@feddit.uk 10 points 6 months ago

Oh boy, this actually made me laugh out loud

[-] kamen@lemmy.world 10 points 6 months ago

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

[-] udon@lemmy.world 71 points 6 months ago
  1. it's easy to make fun of
  2. it makes every other programming language look better in comparison
[-] MsFlammkuchen 64 points 6 months ago* (last edited 6 months ago)
  1. It's not PHP.
  2. I don't know. I didn't think I'd get this far.
[-] bastion@feddit.nl 26 points 6 months ago
  • It's not PHP
  • It's already implemented in browsers
[-] Hexarei@programming.dev 20 points 6 months ago

PHP has gotten really good over the past few versions, actually. Lots of really great stuff has been added, it feels like it resembles rust more every release lol

load more comments (2 replies)
load more comments (1 replies)
[-] SGG@lemmy.world 62 points 6 months ago
  1. It runs in browsers
  2. If you hate your co-workers, then they will also feel your pain.
[-] Tenkard@lemmy.ml 61 points 6 months ago
  1. You can call it "Java" to enrage other programmers
  2. You can compare numbers against strings without wasting time converting them
[-] neclimdul@lemmy.world 11 points 6 months ago

Array(16).join("wat" - 1) + " Batman!";

load more comments (1 replies)
load more comments (5 replies)
[-] AVincentInSpace@pawb.social 57 points 6 months ago
  1. It runs in the browser
  2. Web developers know it already so we might as well
[-] mokus 56 points 6 months ago
  1. Job security
  2. its not COBOL
[-] BeefPiano@lemmy.world 55 points 6 months ago
  1. It has the simplest multi-threaded implementation: no threads!
  2. You can goof off while your build system takes 20 minutes to rebuild a non-compiled language
[-] Hotzilla@sopuli.xyz 15 points 6 months ago

node_modules size of a Linux distro

[-] Skullgrid@lemmy.world 45 points 6 months ago

I am forced to try to get a JS certification.

I am reaching the end of my rope, and starting to think of maybe putting my neck into one.

Isaac Newton said that we see far because we stand on the shoulders of giants.

Javascript is like standing on the shoulders of dwarves with brittle bone disease.

load more comments (1 replies)
[-] Fargeol@lemmy.ml 42 points 6 months ago* (last edited 6 months ago)

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

[-] Skullgrid@lemmy.world 13 points 6 months ago

NaN is of type number. because fuck me.

[-] kevincox@lemmy.ml 10 points 6 months ago

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

load more comments (6 replies)
load more comments (1 replies)
[-] vocornflakes@lemmy.world 38 points 6 months ago
  1. Ubiquitous; insane amount of libraries and probably some of the best documentation of any language
  2. JS lambda function syntax is nice
[-] sirico@feddit.uk 32 points 6 months ago

It leads to typescript

You get surprises from npm

[-] ByteJunk@lemmy.world 27 points 6 months ago

I spent way too long today figuring out why my app was doing something that it's NOT supposed to do on weekends.

I read Luxon's docs (pretty cool lib tbh) again and again, and tried everything I could think of to get isWeekend to return a sane result.

Turns out I was pulling a somewhat older version of Luxon, where isWeekend didn't exist. In any sane language, I expect I'd get a huge warning about a property that doesn't exist, but alas...

Typescript helps me keep my sanity, but juuuuust barely.

[-] mynameisigglepiggle@lemmy.world 22 points 6 months ago* (last edited 6 months ago)

If isWeekend doesn't exist, then the weekend doesn't exist, so it's naturally false.

That's why JavaScript gets pushed so hard - it's part of the capitalist agenda to keep us working 7 days a week

load more comments (9 replies)
[-] kevincox@lemmy.ml 24 points 6 months ago
  1. Is available to be used in website scripting.
  2. Not quite as full of footguns as PHP (although it is close).
[-] xmunk@sh.itjust.works 15 points 6 months ago

PHP is actually quite footgun free these days.

[-] lowleveldata@programming.dev 22 points 6 months ago

await and async

[-] Thann@lemmy.ml 20 points 6 months ago
[-] yogthos@lemmy.ml 19 points 6 months ago

The part that always gets me is when people choose Js for the backend. Like I get that it's the default thing that works on the frontend, so there's some rationale why you might not want to transpile to it from another language. On the backend though, there are so many far better option, why would you willingly go with Js, especially given that you're now forced to do all your IO async.

load more comments (9 replies)
[-] xilliah@beehaw.org 19 points 6 months ago

It has a cup of coffee as logo

[-] BorgDrone@lemmy.one 14 points 6 months ago

That’s Java, not Javascript. Java is to javascript as ham is to hamster.

load more comments (3 replies)
load more comments (1 replies)
[-] Steamymoomilk@sh.itjust.works 18 points 6 months ago

You can make minecraft mods

[-] AVincentInSpace@pawb.social 45 points 6 months ago
[-] derpgon@programming.dev 10 points 6 months ago

Everyone know JavaSript is a Java, but you don't have to compile, so you script in it.

^/s^

load more comments (1 replies)
[-] TrickDacy@lemmy.world 18 points 6 months ago

God people it's getting old

load more comments (6 replies)
[-] KillingTimeItself@lemmy.dbzer0.com 14 points 6 months ago

hmm, let's see.

It's not java.

It's also not a scripting language.

also to the repeat grammar nazi in the comments here, hi, "its"

[-] jve@lemmy.world 26 points 6 months ago

It’s not a scripting language?

load more comments (10 replies)
load more comments (2 replies)
[-] sincle354@kbin.social 13 points 6 months ago

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.

[-] Aurenkin@sh.itjust.works 13 points 6 months ago

Write down any NaN advantages of JavaScript

[-] jordanlund@lemmy.world 12 points 6 months ago
load more comments (7 replies)
[-] heavyboots@lemmy.ml 11 points 6 months ago* (last edited 6 months ago)

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…

[-] someacnt_@lemmy.world 11 points 6 months ago
  1. It at least feels slightly little bit like lisp.
  2. Shit I'm f*ed

.. ah right, it runs on any browser. Lame

[-] sturlabragason@lemmy.world 10 points 6 months ago
load more comments
view more: next ›
this post was submitted on 21 Apr 2024
708 points (100.0% liked)

Programmer Humor

32445 readers
897 users here now

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

Rules:

founded 5 years ago
MODERATORS