diff --git a/manuscript/markdown/References and Rebinding/recipes/map-with.md b/manuscript/markdown/References and Rebinding/recipes/map-with.md index aa69929..16302c8 100644 --- a/manuscript/markdown/References and Rebinding/recipes/map-with.md +++ b/manuscript/markdown/References and Rebinding/recipes/map-with.md @@ -14,7 +14,7 @@ We say that `.map` *maps* its arguments over the receiver array's elements. Or i }) //=> [1, 4, 9, 16, 25] -[^why]: Why provide a map function? well, JavaScript is an evolving language, and when you're writing code that runs in a web browser, you may want to support browsers using older versions of JavaScript that didn't provide the `.map` function. One way to do that is to "shim" the map method into the Array class, the other way is to use a map function. Most library implementations of map will default to the `.map` method if its available. +[^why]: Why provide a map function? Well, JavaScript is an evolving language, and when you're writing code that runs in a web browser, you may want to support browsers using older versions of JavaScript that didn't provide the `.map` function. One way to do that is to "shim" the map method into the Array class, the other way is to use a map function. Most library implementations of map will default to the `.map` method if it's available. This recipe isn't for `map`: It's for `mapWith`, a function that wraps around `map` and turns any other function into a mapping. In concept, `mapWith` is very simple:[^mapWith] @@ -49,4 +49,4 @@ And we'd do that every time we wanted to construct a method that maps an array t [Underscore]: http://underscorejs.org -[^mapWith]: If we were always mapWithting arrays, we could write `list.map(fn)`. However, there are some objects that have a `.length` property and `[]` accessors that can be mapWithted but do not have a `.map` method. `mapWith` works with those objects. This points to a larger issue around the question of whether containers really ought to implement methods like `.map`. In a language like JavaScript, we are free to define objects that know about their own implementations, such as exactly how `[]` and `.length` works and then to define standalone functions that do the rest. \ No newline at end of file +[^mapWith]: If we were always mapWithing arrays, we could write `list.map(fn)`. However, there are some objects that have a `.length` property and `[]` accessors that can be mapWithed but do not have a `.map` method. `mapWith` works with those objects. This points to a larger issue around the question of whether containers really ought to implement methods like `.map`. In a language like JavaScript, we are free to define objects that know about their own implementations, such as exactly how `[]` and `.length` works and then to define standalone functions that do the rest.