Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
typeof vs instanceof vs constructor
Comparing typeof vs instanceof vs .constructor property
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0
Browser:
Chrome 137
Operating system:
Windows
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
typeof check
822010.1 Ops/sec
instanceof check
413248.0 Ops/sec
constructor check
69896.1 Ops/sec
Script Preparation code:
function Ticket(id) { this._id = id; } var testTicket = new Ticket(1); var count = 1000;
Tests:
typeof check
for (var i = 0; i < count; i += 1) { if (typeof testTicket === 'object') { continue; } }
instanceof check
for (var i = 0; i < count; i += 1) { if (testTicket instanceof Ticket) { continue; } }
constructor check
for (var i = 0; i < count; i += 1) { if (testTicket.constructor.name === 'Ticket') { continue; } }