3 ms·
I always name my variables descriptive names. For example, if I am in a loop and the variable represents a "record" I will name it record rather than r. It's m
by eecks 10y ago
I always name my variables descriptive names. For example, if I am in a loop and the variable represents a "record" I will name it record rather than r.
It's much more readable and you're less likely to get name clashes with other functions (r could be lots of things (even in the same file) - render, record, row, red, right)
- tomatsu 10y agoI always go with plural for lists and singular for iteration variables. for (let thing of things) {...}
- TeMPOraL 10y agoPersonally I have a habit of avoiding that, especially in dynamic languages, because a single typo could have nasty consequences there. So I always figure out a synonym, or use a name for the variable that's either more descriptive: for (let particularThing of things) or at least visibly different: for (let th of thigns)
- tomatsu 10y agoThe dynamic languages I primarily use are TypeScript and Dart. I always have enough type information floating around to catch this kind of thing. But even in JavaScript it wouldn't be much of an issue since it will instantly explode on the first run, which is certainly inconvenient, but nothing major.
- euyyn 10y agoIf you name a variable with broad scope "record", though, you deserve hell.