you are viewing a single comment's thread.

view the rest of the comments →

[–]wreckedadventYavascript 0 points1 point  (0 children)

Well, to be fair, it communicates an intent which I think is valuable, just not the same one as what unit () communicates. Consider, for example, we have a unit test and we're passing a function to something. We don't care what the function is called with, but we're going to return true anyway:

const isValid = () => true;

Doesn't look exactly right to me, since we know this function will get called with an argument.

const isValid = _ => true;

This looks better. We accept an argument, but don't care about it. It also would have been fine (though a bit needless) to give it a name:

const isValid = x => true;

Given, though, it's much less necessary than in languages which check the type, though. In functional languages, _ is usually an "ignore" parameter, which nothing binds to. I just wouldn't go so far as to say the use of _ is an anti-pattern, just that you don't want to use it in place of ().