code: function inferVectorDtype(array, defaultDtype) {
    if (isUndefined(defaultDtype)) {
      defaultDtype = 'object';
    }
    var dtype = null;
  
    // Attempt to infer the dtype
    for (var i = 0; i < array.length; i++) {
      var inferredDtype = inferDtype(array[i]);
      if (inferredDtype !== null) {
        if (dtype === null) {
          dtype = inferredDtype;
        }
        if (dtype !== inferredDtype || inferredDtype === 'object') {
          return newVector(array, 'object');
        }
      }
    }
  
    // Use 'defaultDtype' if all inferences were inconclusive
    var naValue;
    if (dtype === null) {
      dtype = defaultDtype;
      if (dtype !== 'object') {
        naValue = NA_VALUE[dtype];
        for (i = 0; i < array.length; i++) {
          array[i] = naValue;
        }
      }
      return newVector(array, dtype);
    }
  
    // Make sure all values are normalized to the right missing value dtype
    if (dtype !== 'object') {
      naValue = NA_VALUE[dtype];
      for (i = 0; i < array.length; i++) {
        if (isMissing(array[i])) {
          array[i] = naValue;
        }
      }
    }
    return newVector(array, dtype);
  }
docs: Creates a new vector backed by the given array by inferring the dtype based on the array's values.  If all elements have the same inferred dtype, this dtype will be used for the resulting vector.  If any two elements have different inferred dtypes, the resulting vector dtype will be "object", and none of the elements of the array will be altered. Any null or undefined elements are ignored since dtype inference is inconslusive for them, but if a non-"object" dtype is inferred for the vector, all missing elements will be standarized to use the same value (according to NA_VALUE).  The 'defaultDtype' argument determines the resulting dtype only if all values are inconclusive. If 'defaultDtype' is undefined it will default to 'object'.