Created
November 29, 2021 14:30
-
-
Save flaviorl-net/ba14de51a7519a1e57ce6e9006a92170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A função não possui nome, mas está sendo atribuida à uma variável, | |
//por meio dessa variável podemos utilizar a função. | |
let funcSoma = function (x, y) { return x + y; } | |
let total = funcSoma(2, 3); | |
console.log(total); | |
//Nesse exemplo, nossa função anonima irá receber outra função como parametro. | |
let minhaFuncao = function (mensagem, funcao) { | |
let resultado = funcao(); | |
let saida = `${mensagem}: ${resultado}`; | |
console.log(saida); | |
} | |
minhaFuncao("Resultado da soma", function() { return 3 + 2; }); | |
minhaFuncao("Resultado da subtracao", function() { return 3 - 2; }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment