Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.prototype.toString.call vs typeof (only isObject)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0
Browser:
Opera 124
Operating system:
Linux
Device Platform:
Desktop
Date tested:
6 months ago
Test name
Executions per second
typeof -> object
6344588.5 Ops/sec
Object.prototype.toString.call -> object
2587097.0 Ops/sec
Script Preparation code:
var types = { array: [1, 2, 3], number: 123, string: '123', map: new Map([ [1, 1], [2, 2], [3, 3] ]), set: new Set([1, 2, 3]), buffer: new ArrayBuffer([1, 2, 3]), boolean: true, arrow: () => {}, function: function() {}, object: {} } var keys = Object.keys(types)
Tests:
typeof -> object
keys.map(key => typeof types[key] === "object")
Object.prototype.toString.call -> object
keys.map(key => Object.prototype.toString.call(types[key]) === '[object Object]')