Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS presence
(version: 0)
Object lookup performance
Comparing performance of:
undefined vs typeof vs in vs hasOwnProperty vs bool
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
Tests:
undefined
undefined !== obj.d;
typeof
'undefined' !== typeof obj.d;
in
'd' in obj;
hasOwnProperty
obj.hasOwnProperty( 'd' );
bool
!! obj.d;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
undefined
typeof
in
hasOwnProperty
bool
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks! The provided JSON represents a benchmark test case for measuring object lookup performance in JavaScript. Specifically, it tests the performance of comparing an object property with different syntaxes and operators. **Benchmark Definition** The `Script Preparation Code` section defines a simple JavaScript object `obj` with five properties: `a`, `b`, `c`, `d`, and `e`. Each test case uses this object to perform a specific comparison. Here are the six test cases: 1. `undefined !== obj.d;`: Tests comparing `undefined` with the value of `obj.d`. 2. `'undefined' !== typeof obj.d;`: Tests comparing a string literal `'undefined'` with the type of `obj.d` using the `typeof` operator. 3. `'d' in obj;`: Tests checking if the property 'd' exists in the object `obj` using the `in` operator. 4. `obj.hasOwnProperty('d');`: Tests checking if the property 'd' is a direct property of `obj`, not inherited from its prototype, using the `hasOwnProperty` method. 5. `!! obj.d;`: Tests converting the value of `obj.d` to a boolean value using the logical NOT operator `!!`. 6. (This test case is skipped in the provided benchmark results) ...
Related benchmarks:
undefined vs. typeof vs. in vs. hasOwnProperty
undefined vs. typeof vs. in vs. hasOwnProperty big object
undefined vs hasOwnProperty
undefined vs evaluation vs hasOwnProperty
in vs hasOwn
Comments
Confirm delete:
Do you really want to delete benchmark?