.constructor vs typeof (v2)

Revision 2 of this benchmark created on


Setup

var stringToCheck = "hello"

Test runner

Ready to run.

Testing in
TestOps/sec
.constructor === String
if (stringToCheck.constructor === String) {}
ready
typeof stringToCheck === 'string'
if (typeof stringToCheck === 'string') {}
ready
if (stringToCheck?.constructor === String) {}
if (stringToCheck?.constructor === String) {}
ready

Revisions

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