Function unit

Create a unit. Depending on the passed arguments, the function will create and return a new type.Unit object. When a matrix is provided, all elements will be converted to units.


unit(unit : string)
unit(value : number, unit : string)


Parameter Type Description
args * | Array | Matrix A number and unit.


Type Description
Unit | Array | Matrix The created unit


var a = unit(5, 'cm');    // returns Unit 50 mm
var b = unit('23 kg');    // returns Unit 23 kg'm');                     // returns Unit 0.05 m

See also

bignumber, boolean, complex, matrix, number, string, createUnit