I dig most of these, but boolean conversion for filter is entirely redundant. Just use identity: .filter(x => x). And the empty object thing seems both pointless and potentially confusing. What is the use case for that?
.filter(Boolean) is much cleaner to read and faster to visually parse. directly conveys intent, and avoids arbitrary use of single character variable names.
Agree to disagree there. To me, “x => x” just reads as “identity”, and the intent is very clear. Using Boolean leads me to believe there is extra work going on for some purpose. There isn’t. So I find it misleading.
For what it’s worth, you could also use a more specific variable name depending on your use case.
3
u/delventhalz May 15 '19
I dig most of these, but boolean conversion for filter is entirely redundant. Just use identity:
.filter(x => x). And the empty object thing seems both pointless and potentially confusing. What is the use case for that?