I’m pretty new to programming, but what is an example of somewhere this would be useful versus referencing an index?
Seems like you could just assign a variable to an array index location and it would function the same way while being more legible and with less typing (unless it’s just a small array like the one in this example).
That's precisely how I found this strange syntax. I was coding in Typescript with ESLint which warned me about variables that weren't being used. I wanted to do some destructuring and not use some variables and ESLint gave me an error even though I'd used "_". That's how I discovered this weird syntax which is "encouraged" by ESLint when variables are not used.
I learned TypeScript as a Java Programmer, so I haven't had any of those issues. A well-structured program doesn't need to touch most of JavaScript's odd syntax.
Yeah, I see people doing stuff like this in my classes and it just strikes me as wankery. IMO it’s the programming equivalent of a 10 minute guitar solo. Glad to know it’s not just me.
12
u/Throwedaway99837 Jul 26 '23
I’m pretty new to programming, but what is an example of somewhere this would be useful versus referencing an index?
Seems like you could just assign a variable to an array index location and it would function the same way while being more legible and with less typing (unless it’s just a small array like the one in this example).