function remove(collection, element) {

  if (!collection || !element) {
    return -1;
  }

  var idx = collection.indexOf(element);

  if (idx !== -1) {
    collection.splice(idx, 1);
  }

  return idx;
}
Failsafe remove an element from a collection

@param {Array<Object>} [collection]
@param {Object} [element]

@return {number} the previous index of the element