this post was submitted on 22 Nov 2025
651 points (98.7% liked)

Programmer Humor

27690 readers
240 users here now

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

founded 2 years ago
MODERATORS
 

cross-posted from: https://lemmy.ml/post/39334581

you are viewing a single comment's thread
view the rest of the comments
[–] mindbleach@sh.itjust.works 3 points 2 weeks ago (17 children)

It's object-oriented; you can assign this to a named variable.

[–] Ghoelian@piefed.social 9 points 2 weeks ago (16 children)

In that case the full thing would be const fun = () => {}

[–] SpaceCowboy@lemmy.ca -5 points 2 weeks ago (15 children)

Yeah for whatever reason, FE devs want to make everything a const. It's like a religious belief or something, it's really kinda weird.

const fun = () => { const something = "whatever" const array = []; array.push(someting)

for (const thing of array) { if (thing === 'whatever') blah(thing) } }

Semicolons? Optional. Which quotes you should use? Whatever you feel like! But you must declare things as a const wherever possible! Even if it's an array that you're going to be changing, declare it as a const because you should know that you can push things into a const array, and since it's possible to declare it as a const, you must declare it as a const.

Why is this? Nobody knows, but it's important to FE devs that you use const.

[–] Ghoelian@piefed.social 9 points 2 weeks ago (1 children)

The reason is very simple, performance. If a value doesn't need to be changed, don't declare it as mutable. This isn't just a front-end thing btw.

load more comments (13 replies)
load more comments (13 replies)
load more comments (13 replies)