Skip to main content

$var

The $var operator retrieves the value of a variable from the current scope.

Input

  • A single string value representing the variable name

Output

  • The value of the variable, or null if the variable is not defined

Examples

Retrieve Variable Value

{
  "$var": [
    "x"
  ]
}
Result: The value of variable x, or null if x is not defined

Use with Let in a Block

{
  "$block": [
    {
      "$let": [
        "name",
        "Alice"
      ]
    },
    {
      "$concat": [
        "Hello, ",
        {
          "$var": ["name"]
        },
        "!"
      ]
    }
  ]
}
Result: "Hello, Alice!"

Variable Not Defined

{
  "$var": [
    "undefined_variable"
  ]
}
Result: null