Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Reduzco, reuso y reciclo
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Lupo Montero
February 21, 2019
Programming
49
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reduzco, reuso y reciclo
LimaJS - 21/02/2019
Lupo Montero
February 21, 2019
Transcript
23 slides
@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!)
More Decks by Lupo Montero
See All by Lupo Montero
Trigonometría Bella
lupomontero
0
52
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
110
Manejo de memoria en Rust: Ownership
lupomontero
0
56
Hola Rust! Aprendiendo con rustlings
lupomontero
1
350
WebThing: construyamos una lámpara 💡
lupomontero
1
110
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
46
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
71
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
380
Other Decks in Programming
See All in Programming
Distance field of Julia set
kinakomoti321
0
330
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
480
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
360
AppFunctionsの内部実装を紐解く
hiroaki404
0
120
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
140
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
Debian JP Projectのサーバー構成
uwabami
1
180
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
400
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
210
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
4k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Crafting Experiences
bethany
1
460
My Coaching Mixtape
mlcsv
0
400
Ruling the World: When Life Gets Gamed
codingconduct
0
450
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
Side Projects
sachag
456
43k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
640
Building an army of robots
kneath
307
47k