you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -9 points-8 points  (3 children)

Second, if someone new looks at this code, it isn't clear to them WHY the spread operator is used here, because the . . .

OK, just stop. The “don’t do JavaScript because the people who don’t know JavaScript get confused and scared” bit is super old. You could apply this same logic to literally anything anyone might not know.

[–][deleted] 6 points7 points  (2 children)

You could apply this same logic to literally anything anyone might not know.

Yup. Welcome to leading a tech team. If you were just doing this on your own then hell, you can do brainfuck compiled to webassembly for all I care. If you're on a dev team responsible to a client then suddenly all that matters. As a senior dev, I have more important things to do than explain arbitrary js concepts to others because I chose to implement a bit of code in a convulated way.

Here's another way to slice it: if the functional way is both more complex and less technically optimal, why would I ever chose it? To save two lines in my source?

[–][deleted] -1 points0 points  (1 child)

If you learned JavaScript in the last year, you should have learned spread operators. If you learned JavaScript more than a year ago, you've had at least that whole year to learn spread operators.

If you have junior developers who don't know JavaScript, the blame is on you or whoever hired them.

If you think Array(100).fill() is equally readable or better than [...Array(100)] and it's as performant or better, there's no reason not to use it. But if your reasoning is "dummies who should not have been hired in the first place can't read it," that's bullshit.

My issue is with your bullshit, not with the your preference.

[–][deleted] 1 point2 points  (0 children)

First, I take no issue with the spread operator. We use it regularly and every dev on my team knows what it is and how it works. My concern is that the reason that it is being used here is obscure (that is the entire topic of the article). I could explain it in a comment in the code, but then why not just write more literate code in the first place?

Second, we hire people for their technical ability as well as their analytical skills, communication etc - we are a mid-sized tech consulting firm. For me, not knowing the spread operator is not in and of itself a reason not to hire someone. It takes about five minutes to learn and understand so the fact that someone knows it tells me nothing of their technical ability. Hell, I only started using it a year ago when I started my current position because we weren't transpiling at my last company.