Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
20 years of Symfony, what's next?
fabpot
2
350
dnx で実行できるコマンド、作ってみました
tomohisa
0
140
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
700
ゲームの物理 剛体編
fadis
0
320
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
230
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
380
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
140
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
2
650
AIコーディングエージェント(skywork)
kondai24
0
150
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
310
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
420
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.5k
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Fireside Chat
paigeccino
41
3.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Embracing the Ebb and Flow
colly
88
4.9k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Scaling GitHub
holman
464
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Building Flexible Design Systems
yeseniaperezcruz
330
39k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
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!)