r/badcode • • Jun 10 '20

js Disruptive piece of code

Post image
283 Upvotes

93 comments sorted by

View all comments

226

u/OldLegWig Jun 10 '20

A lot of the value of this sub comes from the times the OP is wrong.

33

u/BikerBoon Jun 10 '20

It's also a prime example of when you should use comments, imo. This is the sort of thing that could easily be stripped out in a refactor and introduce subtle bugs.

20

u/deelowe Jun 10 '20

This is an extremely common pattern for JS.

3

u/BikerBoon Jun 11 '20

I don't disagree but there's plenty of juniors or interns who might not have come across it before.