Expression Functions Reference

The expression language contains math, string, array, comparison, boolean, and conditional functions. All functions are case-sensitive.

Math Functions 

The math functions perform math operations on numbers. They take numerical arguments. The Corresponding Operator column lists equivalent operators, if any.

FunctionAlternativeUsageDescriptionCorresponding Operator
addconcatadd(1,2)Adds the first argument to the second.+
subsubtractsub(10,2)Subtracts the second argument from the first.-
multmultiplymult(2,10)Multiplies the first argument by the second.*
divdividediv(4,2)Divides the first argument by the second./
modmodulusmod(5,2)Returns the integer remainder resulting from dividing the first argument by the second.%
abs abs(-5)Returns the absolute value of the argument: the same number if the argument is positive, and the number without its negative sign if the number is negative. For example, abs(-5) is 5.None
negnegateneg(100)Reverses the sign of the argument. For example, neg(100) is -100.- (unary)

String Functions 

FunctionAlternativeUsageDescriptionCorresponding Operator
concataddconcat('Hello ', 'world')``add('Walk ', 'the dog')Concatenates the two arguments.+
format format($Label.ns.labelName, v.myVal)Replaces any parameter placeholders with comma-separated attribute values. 
join join(separator, subStr1, subStr2, subStrN)``join(' ','class1', 'class2', v.class)Joins the substrings adding the separator String (first argument) between each subsequent argument. 

The format function works for arguments of type String, Decimal, Double, Integer, Long, Array, String[], List, and Set.

Note

Label Functions 

FunctionUsageDescription
formatformat($Label.np.labelName, v.attribute1 , v.attribute2)``format($Label.np.hello, v.name)Outputs a label and updates it. Replaces any parameter placeholders with comma-separated attribute values. Supports ternary operators in labels and attributes.

Informational Functions 

FunctionUsageDescription
lengthmyArray.lengthReturns the length of an array or a string.  
emptyempty(v.attributeName)Returns true if the argument is empty. An empty argument is undefined, null, an empty array, or an empty string. An object with no properties is not considered empty. The $A.util.isEmpty() method in JavaScript is equivalent to the empty() expression in markup.  

The empty function works for arguments of type String, Array, Object, List, Map, or Set.

Note

{! !empty(v.myArray)} evaluates faster than {!v.myArray && v.myArray.length > 0} so we recommend empty() to improve performance.

Tip

Comparison Functions 

Comparison functions take two number arguments and return true or false depending on the comparison result. The eq and ne functions can also take other data types for their arguments, such as strings.

FunctionUsageDescriptionCorresponding Operator
equalsequals(1,1)Returns true if the specified arguments are equal. The arguments can be any data type.== or eq
notequalsnotequals(1,2)Returns true if the specified arguments are not equal. The arguments can be any data type.!= or ne
lessthanlessthan(1,5)Returns true if the first argument is numerically less than the second argument.< or lt
greaterthangreaterthan(5,1)Returns true if the first argument is numerically greater than the second argument.> or gt
lessthanorequallessthanorequal(1,2)Returns true if the first argument is numerically less than or equal to the second argument.<= or le
greaterthanorequalgreaterthanorequal(2,1)Returns true if the first argument is numerically greather than or equal to the second argument.>= or ge

Boolean Functions 

Boolean functions operate on Boolean arguments. They are equivalent to logical operators.

FunctionUsageDescriptionCorresponding Operator
andand(isEnabled, hasPermission)Returns true if both arguments are true. This function supports only two arguments. Any arguments after the first two are ignored.&amp;&amp; This syntax is awkward in markup so we recommend using the and() function instead when you have two arguments. If you have more than two arguments, you can chain multiple &amp;&amp; operations.
oror(hasPermission, hasVIPPass)Returns true if either one of the arguments is true. This function supports only two arguments. Any arguments after the first two are ignored.|| If you have more than two arguments, you can chain multiple || operations.
notnot(isNew)Returns true if the argument is false.!

Conditional Function 

FunctionUsageDescriptionCorresponding Operator
ifif(isEnabled, 'Enabled', 'Not enabled')Evaluates the first argument as a boolean. If true, returns the second argument. Otherwise, returns the third argument.?: (ternary)