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.Documentation Index
Fetch the complete documentation index at: https://docs.getcargo.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick reference
Strings
Arrays
Utilities
String methods
split
split
Split a string by a delimiter to extract specific parts.Example: Extract domain from email address
| Input | nodes.start.email = "john.smith@acme-corp.com" |
|---|---|
| Output | "acme-corp.com" |
toLowerCase
toLowerCase
Convert a string to lowercase for consistent formatting.Example: Standardize company name
| Input | nodes.start.companyName = "ACME Corporation" |
|---|---|
| Output | "acme corporation" |
toUpperCase
toUpperCase
Convert a string to uppercase.Example: Format country code
| Input | nodes.start.country = "us" |
|---|---|
| Output | "US" |
trim
trim
Remove whitespace from both ends of a string.Example: Clean user input
| Input | nodes.start.name = " John Smith " |
|---|---|
| Output | "John Smith" |
replace
replace
Replace part of a string with another value.Example: Anonymize email domain
| Input | nodes.start.email = "john@competitor.com" |
|---|---|
| Output | "john@[redacted].com" |
Use
replaceAll() to replace all occurrences, not just the first one.Array methods
length
length
Count how many items are present in an array.Example: Count the number of stakeholders found
| Input | nodes.array = ["John Smith", "Sarah Johnson", "Mike Davis", "Lisa Chen"] |
|---|---|
| Output | 4 |
includes
includes
Check if a value exists in an array.Example: Check if the product is in an allowed list
| Input | nodes.start.product = "posters" |
|---|---|
| Allowed | ["posters", "calendars", "books", "cards"] |
| Output | true |
slice
slice
Extract a portion of an array.Example: Limit stakeholders to first 5
| Input | nodes.apollo.stakeholders = ["John", "Sarah", "Mike", "Lisa", "David", "Emma", "Tom"] |
|---|---|
| Output | ["John", "Sarah", "Mike", "Lisa", "David"] |
slice(start, end) extracts elements from index start up to (but not including) end.filter
filter
Create a new array based on a condition.Example: Filter case study URLs
| Input | ["https://example.com/case-studies/tech", "https://example.com/blog", "https://example.com/case-studies/finance"] |
|---|---|
| Output | ["https://example.com/case-studies/tech", "https://example.com/case-studies/finance"] |
join
join
Convert an array to a string with a delimiter.Example: Convert countries to comma-separated string
| Input | nodes.start.countries = ["US", "CA", "UK", "DE"] |
|---|---|
| Output | "US, CA, UK, DE" |
map
map
Transform each element in an array.Example: Add company data to stakeholders
- Input
- Output
find
find
Return the first element that matches a condition.Example: Find the CEO in a stakeholders list
| Input | [{ "name": "John", "title": "CEO" }, { "name": "Sarah", "title": "CTO" }] |
|---|---|
| Output | { "name": "John", "title": "CEO" } |
Returns
undefined if no element matches. Use optional chaining (?.) to safely access properties.concat
concat
Merge two arrays together.Example: Combine prospect lists
| Input | nodes.start.countries1 = ["US", "CA"] and nodes.start.countries2 = ["UK", "DE"] |
|---|---|
| Output | ["US", "CA", "UK", "DE"] |
Date and time
new Date()
new Date()
Create a timestamp.Example: Get current timestamp
| Output | "2024-01-15T10:30:45.123Z" |
|---|
toLocaleDateString()
toLocaleDateString()
Format date in localized format.Example: Format current date
| Output | "1/15/2024" |
|---|
Pass a locale string for different formats:
toLocaleDateString('en-GB') returns "15/01/2024"Mathematical operations
Basic arithmetic
Basic arithmetic
Perform calculations on numbers.Example: Calculate win rate
Other common operations:
| Input | nodes.start.wins = 15, nodes.start.total = 50 |
|---|---|
| Output | 30 |
Common patterns
Conditional logic
Conditional logic
Use ternary operators for simple conditions.Example: Set priority based on score
Nested conditions:
| Input | nodes.start.score = 85 |
|---|---|
| Output | "High Priority" |
Object property access
Object property access
Access nested properties using dot notation.Example: Extract the city from a nested address
- Input
- Output
Null checking
Null checking
Safely access properties that might not exist using optional chaining.Example: Get theme with default fallback
- Input
- Output
Default values
Default values
Provide fallback values when data might be missing.Example: Use a default name when none is provided
| Input | nodes.start.name = undefined |
|---|---|
| Output | "Anonymous" |
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, not1. - Chain methods — You can chain multiple methods together:
{{ nodes.start.email.split('@')[1].toLowerCase() }}

