Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
=== vs shorthand function
multiple equality operators vs shorthand function
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
multiple equality operators
1290090.5 Ops/sec
shorthand function
3353462.0 Ops/sec
multiple equality operators with an object
1402982.4 Ops/sec
shorthand function with an object
5441215.5 Ops/sec
HTML Preparation code:
<a id='foo' href='#' />
Script Preparation code:
var type = Object.prototype.toString.call(document.querySelector("#foo")).slice(8, -1), arrTypes = ["HTMLIFrameElement", "HTMLDocument", "HTMLHeadingElement", "HTMLDivElement", "HTMLSpanElement", "ShadowRoot", "String", "Array", "Function", "HTMLAnchorElement"], oneOf = (v, ...a) => (a.some(e => v === e));
Tests:
multiple equality operators
type === "HTMLIFrameElement" || type === "HTMLDocument" || type === "HTMLHeadingElement" || type === "HTMLDivElement" || type === "HTMLSpanElement" || type === "ShadowRoot" || type === "String" || type === "Array" || type === "Function" || type === "HTMLAnchorElement";
shorthand function
oneOf(type, "HTMLIFrameElement", "HTMLDocument", "HTMLHeadingElement", "HTMLDivElement", "HTMLSpanElement", "ShadowRoot", "String", "Array", "Function", "HTMLAnchorElement");
multiple equality operators with an object
arrTypes[9] === "HTMLIFrameElement" || arrTypes[9] === "HTMLDocument" || arrTypes[9] === "HTMLHeadingElement" || arrTypes[9] === "HTMLDivElement" || arrTypes[9] === "HTMLSpanElement" || arrTypes[9] === "ShadowRoot" || arrTypes[9] === "String" || arrTypes[9] === "Array" || arrTypes[9] === "Function" || arrTypes[9] === "HTMLAnchorElement";
shorthand function with an object
oneOf(arrTypes[9], "HTMLIFrameElement", "HTMLDocument", "HTMLHeadingElement", "HTMLDivElement", "HTMLSpanElement", "ShadowRoot", "String", "Array", "Function", "HTMLAnchorElement");