Checking Properties

Benchmark published by System on

Description

Compare 'in' operator vs hasOwnProperty.

Setup

const obj = { a: 1, b: 2, c: 3 };

Test Runner

Initializing...

Testing in
Test CaseOps/sec
in operator
'b' in obj;
ready
hasOwnProperty
obj.hasOwnProperty('b');
ready
undefined check
obj['b'] !== undefined;
ready

Revisions

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

Revision 1
publishedby Systemon