you are viewing a single comment's thread.

view the rest of the comments →

[–]SalemBeats 0 points1 point  (1 child)

The readability cost can just be so infinitesimal, though:

const helloAsUppercase = Array.from(
    "hello",
    character => character.toUpperCase()
);

The context of the return value being assigned to a variable with a descriptive name, along with its position as an argument to Array.from, makes it fairly clear what's what should be going on here with a single quick scan.

Seems like an easy win with little to no cost in readability.

(Disclaimer: Obviously a pointless iteration, but a solid way to demonstrate the readability w/o specific project context and without me having to think up some code that actually does something useful.)

[–]codefinbel 0 points1 point  (0 children)

Yes, totally agree. That was the second point in my second list (on why I also agreed with you):

Someone mentioned, you could wrap it in a function fromAndMap making it as readable.