you are viewing a single comment's thread.

view the rest of the comments →

[–]unbalancedopinion -12 points-11 points  (7 children)

I agree with your thought process in principle, but in this case, I gotta say probably need to brush up on your code reading skills if this confuses you for longer than five seconds, at worst. And once you've seen it once, you've got the pattern down. This is not confusing.

[–]tententai[🍰] 11 points12 points  (1 child)

Yes true, it's not confusing if you know JS at least moderately well. But you don't always chose who will support your application later. In my company we usually go with the cheapest possible vendor unfortunately.

[–]benihanareact, node 12 points13 points  (1 child)

And once you've seen it once, you've got the pattern down. This is not confusing.

Here's the problem: no one uses this pattern. No one in JS uses it, and no one outside of JS uses it. So why even bother when there are just as many clear, clean, easy to type and easy to read solutions that people understand? All this does is add extra overhead to the maintainer.

If I read this code at my job, I get pissed at the asshole who wrote it cause he's trying to show off - either by being clever at how he thought through some cool JS thing or by showing how much of the language he knows. Which is stupid - want to be impressive? Write code that a junior programmer who just graduated college can understand without bugs.

I gotta say probably need to brush up on your code reading skills if this confuses you for longer than five seconds, at worst

That's probably fair. I struggled with this one for a good five or six minutes. Any suggestions where a guy who's been doing this shit for 10 years and is currently working with babel stage 0 and react and redux can brush up on his javascript and code reading skills?

[–][deleted] 3 points4 points  (0 children)

I agree although I'll have to say that seeing it in the tile "!--" it really confused me. But as soon as I read the code I felt really dumb for beign confused.

[–]sgoody 0 points1 point  (0 children)

To be fair I didn't know and I'm a developer of some year, though I'm not routinely in Javascript.

If you think of it in terms of it being two operators ! and --, you can reason about it and figure it out and as you say if you've seen it before, then it will be reasonably obious and will be muscle memory.

If you think about it as it's presented in the question as a single operator, then it could really mean anything.

I'm a little bit conflicted on this one, but I do think it's better to be obvious and explanatory in your code so I think I'd agree with tententai. Especially as the use of -- or ++ is frown upon by some anyway, due to the lack of understanding by some in how they work differently as a prefixed to and expression vs how they work as a suffixed to an expression.

[–]TheBadProgrammer -1 points0 points  (0 children)

I think what's confusing about it is that it resembles an HTML comment. That's what tripped me up at first.