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
45
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
More Decks by Lupo Montero
See All by Lupo Montero
Trigonometría Bella
lupomontero
0
47
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
110
Manejo de memoria en Rust: Ownership
lupomontero
0
49
Hola Rust! Aprendiendo con rustlings
lupomontero
1
340
WebThing: construyamos una lámpara 💡
lupomontero
1
99
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
40
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
64
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
370
Other Decks in Programming
See All in Programming
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
340
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.6k
30年振りにコンパイラの定数整数除算を改善した
herumi
7
3.1k
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
450
VibeCodingからAgenticWorkflowへ
starfish719
0
730
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
300
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
350
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
360
React本体のコードリーディング
high_g_engineer
1
150
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
1.1k
What's New in Android 2026
veronikapj
0
270
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
550
Writing Fast Ruby
sferik
630
63k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Rails Girls Zürich Keynote
gr2m
96
14k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Embracing the Ebb and Flow
colly
88
5.1k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
930
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
How to train your dragon (web standard)
notwaldorf
97
6.8k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Facilitating Awesome Meetings
lara
57
7.1k
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!)