JavaScript Find String Length - Performance Test

Benchmark created on


Setup

let message = 'JavaScript runs everywhere on everything!'

Test runner

Ready to run.

Testing in
TestOps/sec
Using length Property
console.log(message.length); 
ready
Using split() Method
let characters = message.split('');
console.log(characters.length); 
ready
Using slice() Method
let characters = message.slice();
console.log(characters.length); 
ready
Using for-loop
let stringLength = 0;
for (let i = 0; message[i]; i++) {
  stringLength++;
}
console.log(stringLength); 
ready

Revisions

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