Skip to content

Instantly share code, notes, and snippets.

@viniciusdacal
Last active February 26, 2020 02:14
Show Gist options
  • Save viniciusdacal/c2c100a6e1c5813fedb8b37d69606461 to your computer and use it in GitHub Desktop.
Save viniciusdacal/c2c100a6e1c5813fedb8b37d69606461 to your computer and use it in GitHub Desktop.
//callback
function listarProdutos(data) {
console.log(data.produtos);
}
//callback
function removerProduto() {
console.log('remover produto da tela');
}
function handleListarProduto() {
api.get('/produtos').then(listarProdutos);
}
function handleRemoverProduto(id) {
api.delete(`/produtos/${id}`).then(removerProduto);
}
//========================================================================//
// callback
function duplicar(x) {
return x * 2;
}
// callback
function somentePares(x) {
return x % 2 === 0;
}
const numeros = [1, 2, 3, 4];
const duplicados = numeros.map(duplicar);
const pares = numeros.filter(somentePares);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment