Remove all spaces in a string

Benchmark created on


Setup

const str = 'A string with some spaces in it.'

Test runner

Ready to run.

Testing in
TestOps/sec
replace() simple
str.replace(' ', '')
ready
replace() regex
str.replace(/ /g, '')
ready
replaceAll() simple
str.replaceAll(' ', '')
ready
replaceAll() regex
str.replaceAll(/ /g, '')
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.