Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
var vs const vs let
(version: 1)
Comparing performance of:
var vs let vs const
Created:
2 years ago
by:
Registered User
Jump to the latest result
Tests:
var
var g = 1; var c = g + 1;
let
let g = 1; let c = g + 1;
const
const g = 1; const c = g + 1;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
var
let
const
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
var
161777616.0 Ops/sec
let
171858336.0 Ops/sec
const
167463536.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The provided JSON represents a JavaScript microbenchmarking test case on the MeasureThat.net website. The benchmark compares the performance of three JavaScript variable declarations: `var`, `const`, and `let`. **Variable Declaration Options** 1. **`var`**: The traditional JavaScript variable declaration, which declares a variable that can be reassigned. * Pros: + Wide support across older browsers. * Cons: + Can lead to performance issues due to hoisting and reassignment. 2. **`const`**: A more modern JavaScript variable declaration, which declares a constant that cannot be reassigned after initialization. * Pros: + Improved code readability and maintainability. + Better performance compared to `var`. 3. **`let`**: Another modern JavaScript variable declaration, which declares a block-scoped variable that can be reassigned. * Pros: + Similar syntax to `const`, making it easier to read and write code. + Good performance. **Comparison** The benchmark compares the execution times of each variable declaration option in a simple assignment scenario: ```javascript var g = 1; var c = g + 1; ``` The test cases also include variants with `let` and `const`, which can help identify performance differences between these options. **Library Usage** None of the test cases use any JavaScript libraries. The benchmark focuses solely on comparing the native variable declaration options. **Special JS Features or Syntax** There are no special JavaScript features or syntax used in this benchmark. **Other Alternatives** If you wanted to compare other JavaScript variable declaration options, such as: * **`let const`**: A more modern alternative to `var`, which combines the benefits of `const` and `let`. * **`class-based variables`**: Some newer JavaScript engines support class-based variables, which can provide better scoping and memory management. However, these alternatives are not currently supported by MeasureThat.net.
Related benchmarks:
var vs. const vs. let
var vs let vs const init
let vs const in tight loops
let vs const vs var
Comments
Confirm delete:
Do you really want to delete benchmark?