Slide 43
Slide 43 text
MAP
Apply a function over every element of a collection to
create a new collection of transformed elements.
R
.
m
a
p
(
f
u
n
c
t
i
o
n
(
a
) { r
e
t
u
r
n a
+
3 }
, [
1
, 3
, 5
]
)
; /
/ [
4
, 6
, 8
]
R
.
m
a
p
(
f
u
n
c
t
i
o
n
(
) { r
e
t
u
r
n '
f
o
o
' }
, [
1
, 3
, 5
]
)
; /
/ [
'
f
o
o
'
, '
f
o
o
'
, '
f
o
o
'
]
R
.
m
a
p
(
f
u
n
c
t
i
o
n
(
a
) { r
e
t
u
r
n a
*
a }
, [
1
, 3
, 5
]
)
; /
/ [
1
, 9
, 2
5
]
R
.
m
a
p
(
p
a
r
s
e
I
n
t
, [
'
1
0
'
, '
1
0
'
, '
1
0
'
]
)
; /
/ [
1
0
, 1
0
, 1
0
]
_
.
m
a
p
(
[
'
1
0
'
, '
1
0
'
, '
1
0
'
]
, p
a
r
s
e
I
n
t
)
; /
/ [
1
0
, N
a
N
, 2
] <
- c
l
a
s
s
i
c j
s w
t
f
Present in ES5: Array.prototype.map(mapper)