105
u/warpedspockclone Oct 11 '20 edited Oct 11 '20
In my case, I use const. Y'all can use let.
Edit: to clear up any misunderstanding, here ya go https://youtu.be/AuBC2cwVnG4
44
u/queen-adreena Oct 11 '20
Using const is more optimistic about your chances of staying alive.
10
u/mark_b Oct 11 '20
Forever?
12
Oct 11 '20
All I gotta do is hack into the Matrix and change my stillAlive variable from let to const
Immortality achieved
2
Oct 11 '20
Regenerative medicine researchers around the world are making strides in learning, how we can reduce the impact of biological aging. So we may be looking at quite longer life spans than you may expect.
9
1
1
40
Oct 11 '20
Now wearing one million masks and counting.
Also
snake_case & CapitalCase combined? Wtf
2
u/DrKrepz Oct 11 '20
I like using the former for variable declarations and the latter for functions/methods. Having said that, since I started using Vue a lot it's pretty much all CamelCase, mainly because it feels like the lines between the two have blurred a bit with computed data and props etc.
1
Oct 11 '20
Vue and React classes are Capital Case but you don't invoke them like that
2
u/DrKrepz Oct 11 '20
Well it depends on how you're invoking them, in Vue at least. Still, in vanilla js there is still a good case for using different naming conventions for different contexts.
1
u/ThagAnderson helpful Oct 13 '20
Best practice states that classes and non-ES6 constructor functions should always begin with a capital letter. Nothing to do with Vue or React. The code in the picture would not pass any Javascript styling conventions.
18
16
u/throwaway1253328 Oct 11 '20
- use of var
- snake case variable naming
- upper camel case method naming
- use of while loop
Yikes man
3
u/jasonbbg Oct 11 '20
the fact that u code reviewing an ads
7
u/throwaway1253328 Oct 11 '20
Those are just painful though. It's like if you saw someone playing a video game with an upside-down controller.
0
u/DrKrepz Oct 11 '20
var still had legitimate use cases. If you want a mutable variable that doesn't create a new block of scope, var is a perfectly good choice.
Also, using different naming conventions for variables Vs functions or methods can help to make code more readable.
As for while... I don't use it but interested to know why it might be problematic.
11
u/ricealexander Oct 11 '20
whileis an appropriate loop for this use case, since you don't know how many timesstill_alivewill continue to evaluate totrue.This
whileis smelly because we can't tell what triggers the exit condition. We can't reasonably infer, looking at this code, which function setsstill_alivetofalse.1
2
u/ThagAnderson helpful Oct 13 '20
letdoes not "create a new block of scope", it is "block scoped", meaning it will not be available outside of its current block statement.varstill works perfectly fine for historical reasons, but there is no instance where 'var' cannot be replaced by 'let' using proper programming techniques, and using 'var' is now considered bad practice.Also, using different naming conventions for variables Vs functions or methods can help to make code more readable.
A scenario that defies all current best practice and style conventions for Javascript.
1
Oct 11 '20
To your point on use of
var, perhaps the author(s) of this billboard intended forstill_aliveto be globally scoped for access by other billboards in the area... XDIgnore me, I have a terrible sense of humor.
12
8
u/RUGMJ7443 Oct 11 '20
This is amazing but what if people who don’t know JavaScript see this they will think there’s something wrong with it lol
8
u/kevinmrr Oct 11 '20
Which is like 97% of people, even there. This sign is just for a small handful of people.
I hate Silicon Valley.
3
u/gotta-lot Oct 11 '20
What languages are being used in Silicon Valley?
11
u/kevinmrr Oct 11 '20
English, Spanish, Mandarin, Ethiopian, Vietnamese are five of the most prevalent ones, I think.
2
u/gotta-lot Oct 11 '20
Am I being whooshed? The parent comment said if they didn't understand JavaScript, so I intended language to mean programming language.
1
2
3
u/Macaframa Oct 11 '20
You are seriously underestimating the programmer gentrification infestation going on in the Bay Area.
1
14
Oct 11 '20
I may not be able to create fully fledged web apps yet in js, but I can understand this code and that’s more then I could do last year.
8
u/wesaboo Oct 11 '20
Dude thats what I keep telling myself! One of my initial goals was to understand programminghumor subreddit. Little goals are a great motivator 👍
1
6
5
u/zigzeira Oct 11 '20
ES5
2
u/Macaframa Oct 11 '20
What features in es6 would you use to make this different in any way?
4
u/james527 Oct 11 '20
const still_alive = true;
Make that one immutable.
2
u/Macaframa Oct 11 '20
Const is not immutable per se but go off.
1
u/james527 Oct 12 '20
True, it's just the reference that's immutable.
If we were referencing an array here, instead of a boolean, we'd still be able to change the contents of the array. We just wouldn't be able to reassign the still_alive variable to anything else.
5
4
4
3
u/doulos05 Oct 11 '20
The doctor told me I'm only allowed 1 test a day, so now I'm blocking one of the seats in the clinic for the next 23:59:59.999.
3
u/MobilePenor Oct 11 '20
so, one of these 4 things will change still_alive, eventually?
Nice side effects bro
3
u/SlaimeLannister Oct 11 '20
> Javascript can keep you safe
Statically typed languages would like to have a word with you
1
3
2
2
u/Morphray Oct 11 '20
varinstead oflet?mix of snake case and pascal case instead of camel case?
No way for mortality to end?
😡
2
3
u/MrSandyClams Oct 11 '20
just so you guys know, based on the syntax of the code, this sign could be written in C#, Java, Scala, maybe Kotlin if the author used semicolons liberally, and perhaps still other languages I don't know about, and still be legal and functional. So, not necessarily JS by any means
3
3
Oct 11 '20
This is silly. If any of the inner methods cause still_alive to become false they weren’t good ideas. If they never do then you just made an infinite loop. Also why is js code using snake case?
2
u/gabbywith_awhy Oct 11 '20
The Fact that they used var is making me cringe🥴 but I guess that was the point
1
1
1
u/IBETITALL420 Oct 11 '20
WHO THE F still uses Var in 2020, but those are all very good methods below
3
u/IncyWincySpooder Oct 11 '20
Those of us who have to work in ES5 for a specific health organisation that still restricts some users to only using internet explorer and were still using windows xp until it was hacked a couple of years ago...
1
u/burntrissoto Oct 11 '20
i'm forced to, its unnecessary too seeing as we don't do work on legacy stuff. absolutely hate not being able to use es6.
1
1
1
u/Whereyoursisterwent Oct 11 '20
I understood that reference although I haven't learned about while yet
1
u/Mr_82 Oct 12 '20
Lol I like the subtlety in stating the first line, since if you're reading this you're alive, after all.
1
1
u/Alexith Oct 12 '20
package main
import "fmt"
func main() { const stillAlive bool = false
if (!stillAlive) {
fmt.Println("Six feet below")
}}
//Golang
0
0
-4
0
Oct 11 '20
[deleted]
0
u/haikusbot Oct 11 '20
Shoulda been python. Could
Have just used a covid safe
Library and done!
- swiftrob
I detect haikus. And sometimes, successfully. Learn more about me.
Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"
48
u/benabus Oct 11 '20
But... there's no exit condition. Is this the secret to immortality?