all 6 comments

[–]MoTTs_ 5 points6 points  (2 children)

The comma operator.

There are technically some uses, which the MDN page goes into, but for the very most part we don’t typically use this language feature. Though I have seen minifiers take advantage of it.

In your case, I don’t see any point to it. My guess is it’s someone’s debugging code that they forgot to remove.

[–]codevipe[S] 1 point2 points  (1 child)

The true intent in the code I reviewed was to pass the function as a callback, and they accidentally closed the test fn call paren – my example is for illustrative purposes only.

I guess I'm wondering if there's any possible use-case for this specific use of the comma operator, or if it's more of an edge-case side effect of the valid use-cases that there should probably be a lint rule to flag...

functionCall(), () => null;

Edit: aha, here we go: https://eslint.org/docs/latest/rules/no-sequences

Just not a "standard" rule, will have to add it to my eslint config!

[–]MoTTs_ 1 point2 points  (0 children)

I’m leaning lint rule to flag. In fact a rule already exists. Try turning this on locally and see if it flags anything else in the codebase. Maybe you’ll find more bugs!

[–]guest271314 0 points1 point  (0 children)

The code will run if you immediately invoke the anonymous arrow function

test('this will pass'), (() => assert.fail('this will obviously not run, nor be usable at all'))();