desconstruçao em js

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
sem desconstrução
const xpto = { content: { name: 'xpto', email: 'teste@teste.com'}, id: 1 }
const f = (data) => { 
	return {
		name: data.content.name,
		email: data.content.email,
		id: data.id
	}
}

console.log(f(xpto));
ready
com desconstrução
const xpto = { content: { name: 'xpto', email: 'teste@teste.com'}, id: 1 }
const f2 = (data) => {
	const { content: { name, email}, id } = data;
	return {
		name,
		email,
		id,
	}
}

console.log(f2(xpto));
ready

Revisions

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