Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
empty string 3
Different ways of checking if string is empty
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
not string
176.3M/s
length is 0
171.7M/s
not length
160.2M/s
string equals empty string
157.3M/s
View exact numbers
Test name
Executions per second
✓
not string
176,279,360 Ops/sec
length is 0
171,709,408 Ops/sec
not length
160,182,704 Ops/sec
string equals empty string
157,284,720 Ops/sec
Tests:
not string
function isEmpty(string) { return !string; } const text = 'This is an example of a non empty string'; const empty = ''; const test1 = isEmpty(text); const test2 = isEmpty(empty);
length is 0
function isEmpty(string) { return string.length === 0; } const text = 'This is an example of a non empty string'; const empty = ''; const test1 = isEmpty(text); const test2 = isEmpty(empty);
not length
function isEmpty(string) { return !string.length; } const text = 'This is an example of a non empty string'; const empty = ''; const test1 = isEmpty(text); const test2 = isEmpty(empty);
string equals empty string
function isEmpty(string) { return string.length > 0; } const text = 'This is an example of a non empty string'; const empty = ''; const test1 = isEmpty(text); const test2 = isEmpty(empty);