size¶
The 'size' filter is designed to return the number of elements in an array or the number of characters in a string.
Functionality
- Arrays: If the input value is an array, the
sizefilter returns the number of elements in that array. - Strings: If the input value is a string, the
sizefilter returns the number of characters in that string. - Other Data Types: For other data types, the behavior of the
sizefilter might vary depending on the specific implementation in Experience Builder. In some cases, it might return the number of properties for an object, or it might not be applicable and return an error ornull.
Syntax
Arguments
The size filter does not require any arguments.
Code Samples
Example 1: Size of an Array
Output:
Example 2: Size of a StringOutput:
Outliers and Special Cases¶
- Empty Arrays/Strings: If the input array or string is empty, the
sizefilter returns0. - Null Values: If the input value is
null, thesizefilter typically returns0ornull, depending on how Experience Builder handles null values.
Key Points¶
- The
sizefilter is a convenient way to determine the length or count of elements in a sequence. - It is most commonly used with arrays and strings, but its behavior might differ for other data types.
- When working with custom objects or complex data structures, it is essential to understand how Experience Builder's
sizefilter interacts with those types to ensure correct results.