Welcome to the Linux Foundation Forum!

Chapter 8: Asynchronous Control Flow, sample code.

The code snippets utilize Array.from, which is unnecessary.

The same result can be achieved without it:

const [ bigFile, mediumFile, smallFile ] = Array(3).fill(__filename);

Comments

  • xdxmxc
    xdxmxc Posts: 157

    I tend to stay away from the Array constructor as a best practice, there's a few different overlapping reasons from allocation bugs, to code consistency - the fact you're creating a holey array isn't good. Code moves over time, it's moved by many people, of different skill levels - simply creating a hole is asking for trouble. The moment you start using something for this one case, another dev will use that as a signal for another case - while your case doesn't have bugs, their case definitely could because of the nature of Array. All that being said, even if I agreed with you I wouldn't change it, because you never iterate on established code purely based on opinion.

Categories

Upcoming Training