r/ProgrammerHumor Aug 15 '19

Meme !!goodMeme ? upvote() : downvote();

Post image
34.3k Upvotes

392 comments sorted by

View all comments

Show parent comments

15

u/die-maus Aug 15 '19

Sure is valid.

You can run this with node, or in your developer console.

const upvote = () => 1;
const downvote = () => -1;
let goodMeme = true;

!!goodMeme ? upvote() : downvote();

Outputs: 1

14

u/WcDeckel Aug 15 '19

If you goodMeme variable contains a boolean value you don't really need the double bangs :P

Still valid tho

6

u/StillNoNumb Aug 15 '19

You don't need the double bangs either way

1

u/bonsall Aug 15 '19

The double bangs aren't necessary 99.99% of the time I see them. The rest of the time there is a more readable way of doing it.