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
29
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
30
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
88
Manejo de memoria en Rust: Ownership
lupomontero
0
35
Hola Rust! Aprendiendo con rustlings
lupomontero
1
310
WebThing: construyamos una lámpara 💡
lupomontero
1
71
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
340
Other Decks in Programming
See All in Programming
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
390
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
3
180
CSC307 Lecture 08
javiergs
PRO
0
660
Oxlintはいいぞ
yug1224
5
1.3k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1.1k
Apache Iceberg V3 and migration to V3
tomtanaka
0
140
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
150
Architectural Extensions
denyspoltorak
0
270
dchart: charts from deck markup
ajstarks
3
990
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
組織で育むオブザーバビリティ
ryota_hnk
0
170
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
960
Featured
See All Featured
We Are The Robots
honzajavorek
0
160
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
230
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Exploring anti-patterns in Rails
aemeredith
2
250
The Cult of Friendly URLs
andyhume
79
6.8k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
760
Why Our Code Smells
bkeepers
PRO
340
58k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
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!)