parseInt vs. replace(/px/,'') (v3)

Revision 3 of this benchmark created by danielbushman on


Setup

var elmWidth = '345px';

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt()
parseInt(elmWidth);
ready
replace(/px/,'')
elmWidth.replace(/px/,'');
ready
slice
+elmWidth.slice(0, -2)
ready
parseInt() w/ radix
parseInt(elmWidth, 10);
ready

Revisions

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