Line 6 of this Javascript program is confusing me
<p>In the function <code>takeNormal()</code> below, there is a line that I don't understand at all. It is: </p>

<pre><code>var end = reduce(Math.min, text.length, map(indexOrEnd, ["*", "{"]));
</code></pre>

<p>Specifically, in this function reduce, it has all these different arguments (are they arguments?). How are they processed by reduce? Are they handled one after the other? Or, for example, does <code>Math.min</code> do anything to <code>text.length</code>? How do the different parts in reduce interact and what does reduce ultimately do to them?</p>

<pre><code>  function splitParagraph(text) {
  function indexOrEnd(character) {
    var index = text.indexOf(character);
    return index == -1 ? text.length : index;
  }

  function takeNormal() {
    var end = reduce(Math.min, text.length,
                     map(indexOrEnd, ["*", "{"]));
    var part = text.slice(0, end);
    text = text.slice(end);
    return part;
  }

  function takeUpTo(character) {
    var end = text.indexOf(character, 1);
    if (end == -1)
      throw new Error("Missing closing '" + character + "'");
    var part = text.slice(1, end);
    text = text.slice(end + 1);
    return part;
  }

  var fragments = [];

  while (text != "") {
    if (text.charAt(0) == "*")
      fragments.push({type: "emphasised",
                      content: takeUpTo("*")});
    else if (text.charAt(0) == "{")
      fragments.push({type: "footnote",
                      content: takeUpTo("}")});
    else
      fragments.push({type: "normal",
                      content: takeNormal()});
  }
  return fragments;
}
</code></pre>
