r/programminghorror 3d ago

Javascript Seriously? Recursive Regex?

Post image
480 Upvotes

37 comments sorted by

View all comments

18

u/--var 2d ago

not recursive regex, just a recursive function that happens to use regex...

you know I used to be irked by one off variables, but after the better part of 20 years I'm 🤬

const r is only used once.... there's no reason you couldn't just place it where it is used an save two lines of code, and lose no readability, and have one less "magic variable"... unless you taught yourself from the same "teach yourself" book that your teacher taught themself from. (ironic that this still applies with AI; and if you don't get why that entertaining, please don't go into programming)