Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Number & toLocaleString vs + & toLocaleString vs custom thousands seperator
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0
Browser:
Firefox 121
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
toLocaleString
3144722.0 Ops/sec
custom thousands seperator
4399667.0 Ops/sec
toLocaleString +
3034322.0 Ops/sec
Script Preparation code:
var number = '1234567'; var addThousandsSeperators = (value) => { if (value.length <= 3) return value; return Array.from(value).reduce((acc, x, i, a) => ( (a.length - i) % 3 === 0 && i ? `${acc},${x}` : `${acc}${x}` ), ''); };
Tests:
toLocaleString
Number(number).toLocaleString();
custom thousands seperator
addThousandsSeperators(number);
toLocaleString +
(+number).toLocaleString();