The type of a variable delineates the set of values it can hold. In this document, you will learn about the different simple types a Flow variable can have.
number
The number type can hold hold numeric values, including both integers and floating-point. Number values are written in decimal representation, using the point character to separate the integer and fractional parts.
// Example: Create three variables of type numberlet x =1+2;let y =0.5;let z =-1;
Advanced: Representation of numbers
Under the hood, numbers are represented in 128-bit decimal floating-point format as defined in IEEE 754-2008. This gives them a relatively high accuracy, a range of approximately ±1.0 × 10⁻²⁸ to ±7.9228 × 10²⁸, and a precision of 28-29 digits.
text
The text type, known as "string" or "varchar" in other languages, can hold variable-length sequences of Unicode characters. Literal text values can be written using either single or double quote characters.
A text literal that begins with a double quote may contain single quote characters. The converse is also true.
// Example: Declare two variables of type textlet country ="Netherlands";let city ='Rotterdam';
Advanced: Special characters in literals
Some characters such as line feeds and backspaces must be inserted into the literal by means of an escape sequence. An escape sequence is formed by a backslash character followed by one or many escape sequence characters. For example, if you want to specify a text literal representing several lines of text, the escape sequence \n can be used to insert a line feed character: "first line\nsecond line". Similarly, the double quote character can be inserted into a double quote-delineated text literal by means of the \" escape sequence. For a full list of supported escape sequences, refer to the Appendix on escape sequences.
Advanced: Verbatim literals
When working with Regular expressions, it often useful not to have FlowScript interpret backslashes as escape sequences. In those cases, you can prefix the literal by the @ sign, creating a verbatim literal.
// The @ character creates a verbatim literal// where backslashes are not interpreted as escape sequences.let pattern = @"\w+";
boolean
The boolean type represents a truth value. A variable of type boolean can only be assigned the values true or false.
// Example: Declare two variables of type booleanlet x =true;let y =false;
Boolean values are often used in conjunction with boolean operators.
datetime
The datetime type represents a calendar date and time of day. Unlike numbers, texts and booleans, datetime values have no special literal syntax. Instead, you typically receive them from a Date input, or work with them programmatically using the now function, the date function or any of the functions in the DateTime module.
// Example: Declare a variable of type datetimelet currentDateAndTime =now();
binary
The binary type represents unintepreted variable-length binary data such as an image, an encoded block of text or a PDF document. Binary variables typically orignate from a File gallery or the HTTP module. There is no literal syntax for binary values.
primitive
A value with the primitive type may be either number, text, boolean, datetime, binary or null. Type checking is relaxed for such values: you can freely use a value of type primitive in any situation where a number, text, boolean, etc. is called for. However, the actual value must be compatible with the requested type, or the application will fail at runtime.
// Example: create a function which calculates the square of a number.// Then, pass two values of type primitive into it. The second call will fail.functionsquare(x:number) =>x * x;let x:primitive="1";let y:primitive="this is definitely not a number";// ERROR: This will fail because "y" cannot be converted to a number.returnsquare(x) +square(y);