Functions
Declaração
function myFunction() {
console.log("Hello World!")
}Funções anônimas
let nome = (nome) => nomelet nome = (nome) => {
return nome
}args
function myFunction(...args) {
console.log(...args)
}
myFunction('teste')Closure
function minhaBiblioteca() {
return {
add5() {
return 10 + 5;
},
add7() {
return 10 + 7;
}
}
}
const meuNumero = minhaBiblioteca();
console.log(meuNumero.add5());
console.log(meuNumero.add7());Currying
Currying é o processo de transformar uma função que espera vários argumentos em uma função que espera um único argumento e retorna outra função curried.
Com curried function
Higher Order Functions
Utilizando higher order function
Arrow Functions
Antes
Com arrow function
Spread Operator
Last updated
Was this helpful?