Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Getters vs single function
(version: 0)
Comparing performance of:
object vs function
Created:
9 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function noDeps(change) { if (change >= 0) { return { color: 'green', icon: 'up' } } else { return { color: 'red', icon: 'down' } } } var x = { get positive() { return this.change >= 0; }, get icon() { return this.positive ? 'up': 'down'; }, get color() { return this.positive ? 'green': 'red'; }, }
Tests:
object
x.change = 1; var icon = x.icon; var color = x.color;
function
var y = noDeps(1)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
object
function
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:
.bind() vs function
Noop vs new arrow function call
Noop vs new arrow function calls
Arrow function vs bind function2021-reznik
Arrow function vs bind function creation
Comments
Confirm delete:
Do you really want to delete benchmark?