Skip to content

coerceAll

coerceAll(array, targetType, default?) → array · Type

Coerce all values in an array to a target type.

  • array (required): array of values to coerce

  • targetType (required): target type — "number", "boolean", "string"

  • default (optional): fallback value for failed coercions

utlx
coerceAll(["1", "2", "three", "4"], "number", 0)
// [1, 2, 0, 4]

Released under AGPL-3.0.