Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Reduzco, reuso y reciclo
Search
Lupo Montero
February 21, 2019
Programming
0
22
Reduzco, reuso y reciclo
LimaJS - 21/02/2019
Lupo Montero
February 21, 2019
Tweet
Share
More Decks by Lupo Montero
See All by Lupo Montero
Trigonometría Bella
lupomontero
0
18
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
26
Manejo de memoria en Rust: Ownership
lupomontero
0
18
Hola Rust! Aprendiendo con rustlings
lupomontero
1
210
WebThing: construyamos una lámpara 💡
lupomontero
1
55
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
17
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
19
Primeros pasos con Rust y WebAssembly
lupomontero
0
330
Paralelizando promesas
lupomontero
0
240
Other Decks in Programming
See All in Programming
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
260
Implementing Design Systems in Swift
seyfoyun
0
350
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
410
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
7
1.2k
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
3
300
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
930
Node.js v22 で変わること
yosuke_furukawa
PRO
10
3.8k
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
210
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
1
1.3k
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
AmperとFleetを使ったAndroidアプリ
yoppie
0
240
What We Can Learn From OSS
inouehi
0
430
Featured
See All Featured
Unsuck your backbone
ammeep
663
57k
4 Signs Your Business is Dying
shpigford
176
21k
Git: the NoSQL Database
bkeepers
PRO
423
63k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Making Projects Easy
brettharned
109
5.5k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
RailsConf 2023
tenderlove
7
550
Automating Front-end Workflow
addyosmani
1357
200k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
79
43k
Scaling GitHub
holman
457
140k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Transcript
@lupomontero LimaJS - 21/02/2019
@Laboratoriala @LimaJSorg @NodeSchool @lupomontero @mozillaperu
Qué es reduce? Blah blah blah… • Transformar un arreglo
en un “valor” • Transformar un arreglo en otro “tipo” • Responder preguntas sobre la colección (por ejemplo estadísticas) • Resumir una colección • ...
[any] Array.prototype.reduce(fn, initialValue) The reduce() method executes a reducer function
(that you provide) on each member of the array resulting in a single output value. Fuente: MDN
.reduce .filter .map .forEach
None
[1,2,3,4,5].reduce((prev, item) => prev + item, 0)
Un ejemplo de reduce
Implementación imperativa • Bucle / iteración • Mutación / reasignación
Reglas del juego... • No sentencias / sólo expresiones •
No mutación / no re-asignación • ...
… antes de empezar con la implementación ... • Operador
ternario • Operador de propagación (spread operator) • !! (bang bang! doble negación)
Implementación declarativa • Recursión • Inmutabilidad • Expresiones
Ejemplos de aplicaciones de reduce • map • filter •
join • forEach • ...
map
filter
join
forEach
includes
indexOf
lastIndexOf
reverse
reduceRight
Fin (Gracias!)