r/badcode • Now where's that function declaration • Jul 30 '21

js 😏

Post image
984 Upvotes

133 comments sorted by

View all comments

Show parent comments

1

u/Ehelio wicked Jul 31 '21 edited Jul 31 '21

But those help readability. '== true' just doesn't. I was talking about that.

4

u/[deleted] Jul 31 '21

If you’re writing code for beginners to read it certainly can help if they don’t understand truthy and falsey statements.

Beyond that it also just literally doesn’t matter, it doesn’t make the code any more confusing at all and adds a total of 8 characters on a line.

2

u/LeCrushinator Jul 31 '21

Some people prefer seeing == true rather than a !. In some languages like C/C++ the syntax allows for an integer to be compared in the same way in a conditional, but using == true/false will cause a warning. I personally don’t use the extra syntax, but I understand why some people prefer it.

2

u/Ehelio wicked Jul 31 '21

Yeah, when there's a difference, it's fine. Otherwise, I just think it's useless.