swap variables (v25)

Revision 25 of this benchmark created by daniel on


Description

Various ways of swapping two values.

Setup

var a = 'test';
    var b = 100;

Test runner

Ready to run.

Testing in
TestOps/sec
array
b = [a, a = b][0];
ready
variable
var c = a;
a = b;
b = c;
ready
destructuring assignment
[a, b] = [b, a];
ready
comma operator
a = b + (b = a, 0);
ready

Revisions

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