slice vs spread to copy (v2)

Revision 2 of this benchmark created on


Setup

var arr = [];
    for (var i = 0; i < 100000; i++) {
     arr.push(i);
    };

Test runner

Ready to run.

Testing in
TestOps/sec
slice
const slice = arr.slice()
ready
spread
const spread = [...arr]
ready
structuredClone
const clone = structuredClone(arr)
ready

Revisions

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