Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
class private prop and read prop fix test5
(version: 3)
class private prop and read prop
Comparing performance of:
test1 vs test2 vs test3 vs test4 vs test5 (by extends)
Created:
3 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
class Test1 { constructor(name) { this.name = name; } } class Test2 { constructor(name) { this._name = name; } get name() { return this._name; } } class Test3 { constructor(name) { Object.defineProperties(this, { name: { enumerable : true, configurable: false, get() { return name; } } }); } } class Test4 { #name; constructor(name) { this.#name = name; } get name() { return this.#name; } } class Test5 extends Test4 { } const a20 = new Array(20).fill(undefined); function test1() { const a = new Test1('test'); return a20.map(() => a.name === 'test'); } function test2() { const a = new Test2('test'); return a20.map(() => a.name === 'test'); } function test3() { const a = new Test3('test'); return a20.map(() => a.name === 'test'); } function test4() { const a = new Test4('test'); return a20.map(() => a.name === 'test'); } function test5() { const a = new Test5('test'); return a20.map(() => a.name === 'test'); }
Tests:
test1
test1();
test2
test2();
test3
test3()
test4
test4();
test5 (by extends)
test5();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
test1
test2
test3
test4
test5 (by extends)
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!
Related benchmarks:
Object Property x Local Variable Accessing
Assign vs Destructure
bind props test
Assign object props
Comments
Confirm delete:
Do you really want to delete benchmark?