Skip to main content
Cargo uses JavaScript expressions to manipulate data within workflows. This cheat sheet covers the most commonly used methods for working with strings, arrays, and data transformations.
All expressions must be wrapped in double curly brackets: {{ expression }}

Quick reference

Strings

Arrays

Utilities


String methods

Split a string by a delimiter to extract specific parts.Example: Extract domain from email address
Convert a string to lowercase for consistent formatting.Example: Standardize company name
Convert a string to uppercase.Example: Format country code
Remove whitespace from both ends of a string.Example: Clean user input
Replace part of a string with another value.Example: Anonymize email domain
Use replaceAll() to replace all occurrences, not just the first one.

Array methods

Count how many items are present in an array.Example: Count the number of stakeholders found
Check if a value exists in an array.Example: Check if the product is in an allowed list
Extract a portion of an array.Example: Limit stakeholders to first 5
slice(start, end) extracts elements from index start up to (but not including) end.
Create a new array based on a condition.Example: Filter case study URLs
Convert an array to a string with a delimiter.Example: Convert countries to comma-separated string
Transform each element in an array.Example: Add company data to stakeholders
Return the first element that matches a condition.Example: Find the CEO in a stakeholders list
Returns undefined if no element matches. Use optional chaining (?.) to safely access properties.
Merge two arrays together.Example: Combine prospect lists

Date and time

Create a timestamp.Example: Get current timestamp
Format date in localized format.Example: Format current date
Pass a locale string for different formats: toLocaleDateString('en-GB') returns "15/01/2024"

Mathematical operations

Perform calculations on numbers.Example: Calculate win rate
Other common operations:

Common patterns

Use ternary operators for simple conditions.Example: Set priority based on score
Nested conditions:
Access nested properties using dot notation.Example: Extract the city from a nested address
Safely access properties that might not exist using optional chaining.Example: Get theme with default fallback
Without ?., accessing preferences.theme when preferences is null would throw an error.
Provide fallback values when data might be missing.Example: Use a default name when none is provided

Tips & best practices

  • Use autocomplete — Access the autocomplete feature while writing expressions by pressing / on your keyboard.
  • Node connections matter — You cannot use a node’s outputs in an expression when the node isn’t connected to prior nodes in the execution logic.
  • Zero-indexed arrays — Arrays in JavaScript are zero-indexed. The first element is at index 0, not 1.
  • Chain methods — You can chain multiple methods together: {{ nodes.start.email.split('@')[1].toLowerCase() }}