This also turns out to be even faster in my benchmarks - this will be due to the regular expression engine being highly optimised and built into the browser. My results from the perf.link site (which doesn't seem to want to let me copy a link directly to the benchmark for some reason...) are as follows:
Another alternative would be using a regular expression, which is quite nice and compact:
This also turns out to be even faster in my benchmarks - this will be due to the regular expression engine being highly optimised and built into the browser. My results from the
perf.link
site (which doesn't seem to want to let me copy a link directly to the benchmark for some reason...) are as follows:regexCapitalize
capitalize2
capitalize
That's awesome. Hell lot of differenceπ₯