4 ms·
If you read the article he makes a point about not using intermediate arrays and .join()
by augusto-moura 6y ago
If you read the article he makes a point about not using intermediate arrays and .join()
- Ciantic 6y agoThat's a good point, but my post didn't have any grand point :) I was hoping other people to come up modern solutions to this same original problem. Even my solution is questionable, because it relies on generating new URLSearchParams with strings, if one wants to be secure the reduce should take URLSearchParams as accumulator and add the items there.
- kbenson 6y agoIs creating an array really more costly than altering a string? I think it may depend on how much condensing of params you expect compared to singular params. The things being optimized for also may have changed over the intervening decade. That's the problem with optimizing something without respect for it's intended common workload, or expecting those justifications to hold over time in all cases. Edit: Woah, made a hash of that before going in and fixing all the typos from my phone keyboard.