githubEdit

map

The map function can be used to transform the contents of an array. It's functions in a similar way to javascripts Array.prototype.maparrow-up-right.

Examples

Simple addition

[1, 2, 3].map($this + 1)
// [2, 3, 4]

Using $key for the index

[10, 20, 30].map($key)
// [0, 1, 2]
[10, 20, 30].map($key + $this)
// [10, 21, 32]

Extracting nested properties

[
    {"x": "foo"},
    {"x": "bar"},
    {"x": "baz"}
].map(x)
// ["foo", "bar", "baz"]

Fizzbuzz

Given numbers.json

Last updated