function Unit (value, valuelessUnit) {
    if (!(this instanceof Unit)) {
      throw new Error('Constructor must be called with the new operator')
    }

    if (!(value === null || value === undefined || isNumeric(value) || isComplex(value))) {
      throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined')
    }

    this.fixPrefix = false // if true, function format will not search for the
    // best prefix but leave it as initially provided.
    // fixPrefix is set true by the method Unit.to

    // The justification behind this is that if the constructor is explicitly called,
    // the caller wishes the units to be returned exactly as supplied.
    this.skipAutomaticSimplification = true

    if (valuelessUnit === undefined) {
      this.units = []
      this.dimensions = BASE_DIMENSIONS.map(x => 0)
    } else if (typeof valuelessUnit === 'string') {
      const u = Unit.parse(valuelessUnit)
      this.units = u.units
      this.dimensions = u.dimensions
    } else if (isUnit(valuelessUnit) && valuelessUnit.value === null) {
      // clone from valuelessUnit
      this.fixPrefix = valuelessUnit.fixPrefix
      this.skipAutomaticSimplification = valuelessUnit.skipAutomaticSimplification
      this.dimensions = valuelessUnit.dimensions.slice(0)
      this.units = valuelessUnit.units.map(u => Object.assign({}, u))
    } else {
      throw new TypeError('Second parameter in Unit constructor must be a string or valueless Unit')
    }

    this.value = this._normalize(value)
  }
A unit can be constructed in the following ways:

    const a = new Unit(value, valuelessUnit)
    const b = new Unit(null, valuelessUnit)
    const c = Unit.parse(str)

Example usage:

    const a = new Unit(5, 'cm')               // 50 mm
    const b = Unit.parse('23 kg')             // 23 kg
    const c = math.in(a, new Unit(null, 'm')  // 0.05 m
    const d = new Unit(9.81, "m/s^2")         // 9.81 m/s^2

@class Unit
@constructor Unit
@param {number | BigNumber | Fraction | Complex | boolean} [value]  A value like 5.2
@param {string | Unit} valuelessUnit   A unit without value. Can have prefix, like "cm"