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
43
0
Share
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
41
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
100
Manejo de memoria en Rust: Ownership
lupomontero
0
46
Hola Rust! Aprendiendo con rustlings
lupomontero
1
330
WebThing: construyamos una lámpara 💡
lupomontero
1
85
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
32
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
56
Primeros pasos con Rust y WebAssembly
lupomontero
0
540
Paralelizando promesas
lupomontero
0
360
Other Decks in Programming
See All in Programming
The NotImplementedError Problem in Ruby
koic
1
560
ふつうのFeature Flag実践入門
irof
7
3.5k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
270
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
610
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
今さら聞けないCancellationToken
htkym
0
220
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
110
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
170
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
100
Swiftのレキシカルスコープ管理
kntkymt
0
210
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
440
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
820
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
130
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Technical Leadership for Architectural Decision Making
baasie
3
400
Being A Developer After 40
akosma
91
590k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.6k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
770
Paper Plane (Part 1)
katiecoart
PRO
0
8.5k
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!)