Var initialization vs. Parameter Initialization

Benchmark created on


Description

Testing difference between declaring function-scoped variables using var against declaring as un-passed parameters.

Preparation HTML

<script>
  function varNoComma() {
    var a, b;
    a = 10;
    b = 20;
    return a * b;
  }
  
  function varPreInit() {
    var a = 10,
        b = 20;
    return a * b;
  }
  
  function parameters(a, b) {
    a = 10;
    b = 20;
    return a * b;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Declaring using var and no values
varNoComma();
ready
Declaring using var with values
varPreInit();
ready
Declared using parameters
parameters();
ready

Revisions

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