Unreadability of JS, #1394


#1

Maybe I am getting all curmedgeony, but if I saw that code in regular usage, I wouldn’t know where to begin :stuck_out_tongue:


#2

And the author probably would not know what is going on too six months or more after it was written.


#3

Here you have one of those operator precedence things that, unless you know, you don’t really know. In a code review, I would suggest adding parens to make it clear the result of the whole expression is being spread.

The other bit is the behavior of object spread on non-spreadable values (not just falsey). I guess here you either know or don’t. But it’s a little confusing in the object spread case because unlike array spread, object spread won’t error when attempting to spread an non-spreadable value. Array spread, on the other hand, requires iterables to spread (object spread accepts any value with own properties).

Note: document.all is a falsy value that will spread, but thats just because document.all is a monstrosity.


#4

So the bigger question is, is there any code that :sen: @senocular doesn’t understand? :stuck_out_tongue_winking_eye:


#5

Well, first you criticize the trailing comma and semicolon. And obj isn’t a great middle ground between concision and clarity. [/s]


The main thing I noticed about this thread is that 1394, while seeming like a random number, is the IEEE standard number for FireWire:


Tragically, yes, it’s the code that powers his own, mechanical heart.


#6

:nerd_face: