function pushEncodedKeyValuePair(pairs, key, val) {
  if (Array.isArray(val)) {
    return val.forEach(function(v) {
      pushEncodedKeyValuePair(pairs, key, v);
    });
  }
  pairs.push(encodeURIComponent(key)
    + '=' + encodeURIComponent(val));
}
Helps 'serialize' with serializing arrays.
Mutates the pairs array.

@param {Array} pairs
@param {String} key
@param {Mixed} val