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
28
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
26
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
74
Manejo de memoria en Rust: Ownership
lupomontero
0
32
Hola Rust! Aprendiendo con rustlings
lupomontero
1
310
WebThing: construyamos una lámpara 💡
lupomontero
1
67
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
27
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
38
Primeros pasos con Rust y WebAssembly
lupomontero
0
490
Paralelizando promesas
lupomontero
0
340
Other Decks in Programming
See All in Programming
rage against annotate_predecessor
junk0612
0
170
私の後悔をAWS DMSで解決した話
hiramax
4
210
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
10
4k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
300
個人軟體時代
ethanhuang13
0
320
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
430
AIコーディングAgentとの向き合い方
eycjur
0
270
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
530
Navigation 2 を 3 に移行する(予定)ためにやったこと
yokomii
0
180
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
440
Swift Updates - Learn Languages 2025
koher
2
470
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
The Language of Interfaces
destraynor
161
25k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Navigating Team Friction
lara
189
15k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
51
5.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
580
Writing Fast Ruby
sferik
628
62k
Optimizing for Happiness
mojombo
379
70k
Side Projects
sachag
455
43k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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!)