Manipulate

How to manipulate numbro numbers (not used often, but still useful).

Operations

numbro provides a set of basic operations to apply to numbers.

var number = numbro(1000);

var added = number.add(10);
// 1010
Before Function After
1000 .add(100) 1100
1100 .subtract(100) 1000
1000 .multiply(100) 100000
100000 .divide(100) 1000

Value

The value of a numbro is always available via the value function.

var number = numbro(1000);

var string = number.format('0,0');
// '1,000'

var value = number.value();
// 1000

Set

Set the value of a numbro.

var number = numbro(10);

number.set(1000);

var value = number.value();
// 1000

Difference

Find the difference between your numbro object and a numeric value.

var number = numbro(1000),
value = 100;

var difference = number.difference(value);
// 900

Clone

Clone any numbro as easy as using clone.

var a = numbro(1000);
var b = numbro(a);
var c = a.clone();

var aVal = a.set(2000).value();
// 2000

var bVal = b.value();
// 1000

var cVal = c.add(10).value();
// 1010