Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
27
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
81
Manejo de memoria en Rust: Ownership
lupomontero
0
34
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
42
Primeros pasos con Rust y WebAssembly
lupomontero
0
500
Paralelizando promesas
lupomontero
0
340
Other Decks in Programming
See All in Programming
Developing static sites with Ruby
okuramasafumi
0
290
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
720
dotfiles 式年遷宮 令和最新版
masawada
1
770
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
430
Cell-Based Architecture
larchanjo
0
120
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
4
870
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
150
JETLS.jl ─ A New Language Server for Julia
abap34
1
400
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
150
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
340
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
140
エディターってAIで操作できるんだぜ
kis9a
0
730
Featured
See All Featured
Six Lessons from altMBA
skipperchong
29
4.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Optimizing for Happiness
mojombo
379
70k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
Agile that works and the tools we love
rasmusluckow
331
21k
Code Reviewing Like a Champion
maltzj
527
40k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.4k
Code Review Best Practice
trishagee
74
19k
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!)