4 ms·
I use underscore to prevent shadowing of variables names. Not sure where I picked up that habit though.
by phist_mcgee 2y ago
I use underscore to prevent shadowing of variables names. Not sure where I picked up that habit though.
- lelandfe 2y agoI've seen that before. A related conventional use of underscores in JS variable names is when "discarding" values in positional settings, like destructuring arrays. E.g. `const [_, a, b] = triple` In general, underscores in JS seem to be used to help call out what to ignore or what is less important.
- fennecbutt 2y agoYou've been able to `const [, a, b] = tuple;` for a wee while now FYI. But yeah for every other time most linters will accept _ as "ignore this".
- phist_mcgee 2y agoI had no idea that was a thing! Thanks for teaching me something today.
- lelandfe 2y agoOh yeah, I always forget about that.