Skip to main content

Max Array

This node finds the maximum value in an array of numbers or strings.

The Max Array node can find the largest numeric value or the alphabetically last string in an array, with support for object arrays.

The Max Array node processes arrays to find the maximum value. For numeric arrays, it returns the mathematically largest number. For string arrays, it returns the alphabetically last string. For object arrays, it can extract values using a key path and find the maximum of those values.

Inputs

Input

DataDescription
ArrayThe array to process (numbers, strings, or objects)

Object Options

DataDescription
Key PathPath to extract values from objects (required for object arrays)

Actions

SignalDescription
DoTriggers the maximum calculation

Outputs

DataDescription
MaximumThe maximum value found in the array
SignalDescription
DoneTriggered when the calculation is complete

Usage

The Max Array node automatically detects the array type and performs the appropriate operation:

Numeric Arrays

  • Finds the mathematically largest number
  • Filters out null/undefined values
  • Returns 0 for empty arrays

String Arrays

  • Finds the alphabetically last string (using lexicographical ordering)
  • Filters out null/undefined values
  • Returns 0 for empty arrays

Object Arrays

  • Requires a Key Path to specify which property to extract
  • Supports nested object access using comma-separated paths
  • Can find maximum of numeric or string properties

Example Use Cases

  1. Data Analytics: Find peak values, highest scores, or maximum prices
  2. Game Development: Determine highest damage, maximum level, or best performance
  3. Financial Analysis: Find maximum transaction amounts or highest costs
  4. UI Development: Calculate maximum content sizes or largest dimensions
  5. Quality Control: Identify maximum error rates or peak usage values

Key Path Examples

For object arrays, use the Key Path to specify which property to compare:

// For objects like: [{score: 85}, {score: 92}, {score: 78}]
Key Path: "score" // Result: 92

// For nested objects: [{player: {points: 150}}, {player: {points: 200}}]
Key Path: "player,points" // Result: 200

// For string comparison: [{name: "Alice"}, {name: "Bob"}, {name: "Charlie"}]
Key Path: "name" // Result: "Charlie" (alphabetically last)

Comparison Examples

Array TypeExample InputResult
Numbers[1, 5, 3, 9, 2]9
Strings["apple", "zebra", "banana"]"zebra"
Objects[{val: 10}, {val: 25}, {val: 15}]25 (with Key Path: "val")

Error Handling

The node will handle errors gracefully:

  • Empty arrays return 0 as the default maximum
  • Invalid key paths throw descriptive error messages
  • Non-array inputs are rejected with clear error messages
  • Arrays exceeding 1,000,000 elements are rejected for performance
  • Object arrays without a key path will generate an error

Performance Considerations

  • The node uses JavaScript's built-in Math.max() for numeric arrays
  • String comparison uses lexicographical sorting
  • Large arrays (>1M elements) are rejected to prevent performance issues
  • Memory usage scales linearly with array size