shallow cloning (v4)

Revision 4 publishedon

Setup

const data = { x: -43432, y: 321, rotation: .43, scaleX:0.9, scaleY: 1.1, skewX: 1.2, skewY: 0.101321 };

function useClone(clone) {
	for (let i=0; i<10; i++) {
		const { x, y, rotation, scaleX, scaleY, skewX, skewY } = clone;
		const sum = x + y + rotation + scaleX + scaleY + skewX + skewY;
	}
}

Test Runner

Initializing...

Testing in
Test CaseOps/sec
structuredClone
useClone(structuredClone(data))
ready
spread destruct
useClone({...data});
ready
manual 1
const { x, y, rotation, scaleX, scaleY, skewX, skewY } = data;
useClone({ x, y, rotation, scaleX, scaleY, skewX, skewY });
ready
manual 2
useClone({ x: data.x, y: data.y, rotation: data.rotation, scaleX: data.scaleX, scaleY: data.scaleY, skewX: data.skewX, skewY: data.skewY });
ready
manual 3
const { x, y, rotation, scaleX, scaleY, skewX, skewY } = data;
useClone({ x:x, y:y, rotation:rotation, scaleX:scaleX, scaleY:scaleY, skewX:skewX, skewY:skewY });
ready
Object.assign 1
useClone(Object.assign({ x: 0, y: 0, rotation: 0, scaleX: 0, scaleY: 0, skewX: 0, skewY: 0 }, data));
ready
Object.assign 2
useClone(Object.assign({}, data));
ready
Object.create
useClone(Object.create(data))
ready

Revisions

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

Revision 1
publishedon
Revision 2
publishedon
Revision 3
publishedon
Revision 4
publishedon