DEV Community

loading...

Discussion on: Build a Simple Chess AI in JavaScript

Collapse
rockykev profile image
Rocky Kev • Edited

I've taken Kyle Simpson's (Of You Don't Know JS) course and he has a lot to say about var vs let/const. I don't agree with his thoughts, but it did gave me pause.

His stance is that he uses var pretty often and the problems people actually had versus what TC39's specified isn't solving the real problems.

Again, I'm not super in agreement. But I definitely jumped off the bandwagon of declaring var as evil, and everything should be let/const. I wish I could find a public blog post where he articulates it better. But it's one (of his many) frontend master courses where he goes on that rant.

Collapse
katsos profile image
Nikos Katsos

I'm working in the industry for 8+ years, writing frontend & backend javascript every day - all day since I've been taught.
I cannot mention enough how evil & unpredictable var can be. Especially if your team has a junior or two, it is guaranteed that var will lead you to problems.

I recommend you to replace them. Scoped variables are your friends.
If you insist to use var, I'm gonna tell you "I told ya"

Thread Thread
rockykev profile image
Rocky Kev

I'm not disagreeing with you. And I can point to my industry experience as well if you want to go there. I'm simply sharing a perspective that made me reconsider my own stance.

And again, I disagree with a lot of his perspectives - but this one was something that made me ponder. Kyle Simpson also points out the reasoning for why he came about that, and I wish I could find the spot in his lecture. It was a fascinating perspective to say the least.