Created
July 30, 2016 19:35
-
-
Save alanyoshida/2e5d8c5682b4da4be0af6221515b47e1 to your computer and use it in GitHub Desktop.
Exemplo de Currying com JS
This file contains hidden or 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
var filmes = [ | |
{ name: 'Matrix', genero: 'acao'} | |
,{ name: 'Mad Max', genero: 'acao'} | |
,{ name: 'Interestelar', genero: 'ficcao cientifica'} | |
,{ name: 'A origem', genero: 'ficcao cientifica'} | |
,{ name: 'Seven', genero: 'policial'} | |
]; | |
var hasGenero = function(genero){ | |
return function(obj){ | |
return obj.genero === genero; | |
} | |
}; | |
var FilmesAcao = filmes.filter(hasGenero('acao')); | |
console.log('Filmes de acao: \n', FilmesAcao); | |
console.log('\n'); | |
var FilmesFiccao = filmes.filter(hasGenero('ficcao cientifica')); | |
console.log('Filmes de ficcao cientifica: \n',FilmesFiccao); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment