The arguments object (v7)

Revision 7 of this benchmark created by Yehor Lvivski on


Description

How slow is the use of arguments?

Preparation HTML

<script>
  function a() {
   return [arguments[0], arguments[1], arguments[2]];
  }
  
  function b() {
   return arguments;
  }
  
  function c(arg1, arg2, arg3) {
   return [arg1, arg2, arg3];
  }

  function d(arr) {
   return [arr[0], arr[1], arr[2]];
  }

  function e(arr) {
   return arr;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
arguments object, accessing individual args
a('foo', 'bar', 42);
ready
arguments object
b('foo', 'bar', 42);
ready
Regular arguments
c('foo', 'bar', 42);
ready
Array from array
d(['foo', 'bar', 42]);
ready
Return array
e(['foo', 'bar', 42]);
ready

Revisions

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