In truth, this array-of-arrays representation is used because it makes geometry processing more straightforward, which we'll see later on. To use these tables for rendering, we must flatten each to a single linear array. This JavaScript function does so, returning its input in a new, flat array.
function flatten(a) {
return a.reduce(function (b, v) { b.push.apply(b, v); return b }, [])
}