574
you are viewing a single comment's thread
view the rest of the comments
[-] sugar_in_your_tea@sh.itjust.works 3 points 4 days ago* (last edited 4 days ago)

Modern JavaScript style recommends using arrow functions for anything that doesn't need a context. Consider adjusting your code to the arrow function syntax:

const addNumbers = (a, b) => a + b;

Not only is this syntax shorter, it also gives you the benefits of a constant function. You can use it the same way you did in your existing code:

console.log(addNumbers(3, 5));  // Outputs: 8

For more JavaScript style suggestions, reply with more code.

this post was submitted on 04 Jan 2025
574 points (97.8% liked)

Greentext

4757 readers
307 users here now

This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.

Be warned:

If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.

founded 1 year ago
MODERATORS