Skip to content

Amount

isZero

1.0.0

Checks if an amount is exactly zero by comparing the internal cents value to zero.

amount.isZero();
  • Returns a boolean value indicating if the amount is zero
  • Compares against the internal cents representation for precision
  • Works with any currency
  • Simple and intuitive API
  • No side effects - read-only operation
  • Comprehensive testing
ArgTypeDefault ValueRequired
No arguments required

From an Amount instance, use the isZero() method to check if the amount is exactly zero.

import { amount } from '@inpulse-ui/utils';
const zeroAmount = amount(0, 'USD');
const result = zeroAmount.isZero();
console.log(result); // true

It returns false for non-zero amounts:

const positiveAmount = amount(100, 'EUR');
const negativeAmount = amount(-50, 'GBP');
console.log(positiveAmount.isZero()); // false
console.log(negativeAmount.isZero()); // false

Works with decimal values:

const smallAmount = amount(0.01, 'USD');
const zeroDecimal = amount(0.00, 'USD');
console.log(smallAmount.isZero()); // false
console.log(zeroDecimal.isZero()); // true

Useful for conditional logic:

const balance = amount(0, 'USD');
if (balance.isZero()) {
console.log('Account has no balance');
} else {
console.log(`Current balance: ${balance.format()}`);
}
// Output: "Account has no balance"

Comparison with arithmetic results:

const value = amount(100, 'USD');
const same = amount(100, 'USD');
const difference = value.subtract(same);
console.log(difference.isZero()); // true (100 - 100 = 0)

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.