39
u/jmswlltt Jan 21 '21
To be fair !!istrue will always be true
40
u/RapeApe Jan 21 '21
...hence the post title ;)
It turns out
istruewas never actually referenced anywhere else in the code, which is why it's underlined with a squiggly... (no-unused-vars)2
u/PrydeRage Jan 21 '21
And here I was thinking that squiggly line was because the line isn't terminated with a semicolon (Yes I know JS allows this but I don't)
3
u/RapeApe Jan 21 '21
I use standardjs.
Takes a little getting used to, but once you do, semicolons seem weird.
-6
66
u/ce-walalang Jan 21 '21
Image Transcription: Code
var istrue
if ($('#isEdit').val() == 1) {
istrue = 'true'
} else {
istrue = 'false'
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
6
18
6
6
4
1
Jan 21 '21
The biggest sin is using jquery in 2021
2
u/RapeApe Jan 21 '21
You say that now, but you haven’t seen the rest of the code... 😱
It’s gonna get a complete rewrite soon, but for now I’m just trying to patch up some show-stopping bugs
1
u/Ahajha1177 Jan 21 '21
So just to get this straight, if they had just used normal, not-string 'true' and 'false' in the first place, all of this code would be redundant?
1
u/GavinZac Jan 21 '21
Just use the 1 and the 0 by themselves instead of wasting all those characters on rue and alse
This post brought to you by Perl Gang
1
1
u/Ahajha1177 Jan 21 '21
I meant the literal booleans, not 1 and 0, which are technically what they are anyways, but it's better to think of them as booleans directly.
1
1
1
1
0
Jan 21 '21
[deleted]
1
u/Golden_Lynel Jan 21 '21
Genuinely asking, whats wrong with it?
0
Jan 21 '21
[deleted]
1
u/Golden_Lynel Jan 21 '21
Which part? The "else"?
10
142
u/RapeApe Jan 21 '21
Found this snippet in our production code. Twice.