Skip to main content

Length

Uncontrolled node

Overview

The Length node calculates the size or count of various data types. It accepts lists (arrays), dictionaries (objects), or text strings as input and outputs the corresponding length:

  • For lists: returns the number of elements
  • For dictionaries: returns the number of keys
  • For text: returns the character count (including spaces)

This is an uncontrolled node, meaning it automatically computes and outputs the length whenever the input data changes, without requiring an event trigger.

Inputs

InputTypeDescriptionDefault
ObjectDataThe item to measure. Can be a list, dictionary, or text string.-

Outputs

OutputTypeDescription
LengthNumberThe calculated length based on input type: count of items in a list, count of keys in a dictionary, or character count in text. Returns 0 if the input type is not recognized.

Runtime Behavior

The Length node evaluates the input data type at runtime:

  • Arrays: Uses the array's .length property
  • Strings: Uses .length to count characters (including whitespace)
  • Objects: Uses Object.keys(obj).length to count enumerable keys
  • Other types: Returns 0

No default values are required as the node simply measures whatever is passed to it.

Example

Scenario: Counting items in a shopping list

  1. Connect a List node containing ["Apples", "Bananas", "Oranges"] to the Object input
  2. The Length output will return 3

Scenario: Measuring text input

  1. Connect a Text node containing "Hello World" to the Object input
  2. The Length output will return 11 (including the space)

Scenario: Counting dictionary keys

  1. Connect a Dictionary node containing {"name": "John", "age": 30} to the Object input
  2. The Length output will return 2