Skip to content

Instantly share code, notes, and snippets.

@suissa
Created September 4, 2015 02:13
Show Gist options
  • Save suissa/258070ec1323783f83fa to your computer and use it in GitHub Desktop.
Save suissa/258070ec1323783f83fa to your computer and use it in GitHub Desktop.
Examples of high order functions in JavaScript #01
function somar(x, y) {
return x + y;
};
function subtrair(x, y) {
return x - y;
};
function multiplicar(x, y) {
return x * y;
};
function dividir(x, y) {
return x / y;
};
function calcular(op, x, y) {
return op(x, y);
};
calcular(somar, 400, 20); // 420
calcular(subtrair, 700, 34); // 666
calcular(multiplicar, 333, 2); // 666
calcular(dividir, 840, 2); // 420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment