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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Lupo Montero
February 21, 2019
Programming
0
35
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
32
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
89
Manejo de memoria en Rust: Ownership
lupomontero
0
38
Hola Rust! Aprendiendo con rustlings
lupomontero
1
320
WebThing: construyamos una lámpara 💡
lupomontero
1
74
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
29
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
48
Primeros pasos con Rust y WebAssembly
lupomontero
0
520
Paralelizando promesas
lupomontero
0
350
Other Decks in Programming
See All in Programming
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
Data-Centric Kaggle
isax1015
2
780
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
470
CSC307 Lecture 08
javiergs
PRO
0
670
並行開発のためのコードレビュー
miyukiw
0
1.1k
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
4k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
MUSUBIXとは
nahisaho
0
140
CSC307 Lecture 03
javiergs
PRO
1
490
CSC307 Lecture 04
javiergs
PRO
0
660
CSC307 Lecture 01
javiergs
PRO
0
690
Featured
See All Featured
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Paper Plane
katiecoart
PRO
0
46k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
A better future with KSS
kneath
240
18k
Become a Pro
speakerdeck
PRO
31
5.8k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
67
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
310
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
170
Side Projects
sachag
455
43k
WCS-LA-2024
lcolladotor
0
450
How STYLIGHT went responsive
nonsquared
100
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!)