Expressions

In addition to the basic primitives an operations this language also has some additional expression syntax.

Identifiers

Variables created with a const or let declaration can be referenced by their names.

const SECRET_NUMBER = 123;
const MORE_SECRET_NUMBER = SECRET_NUMBER + 1;

Groups

If you need to overcome the operator priority you can use groups to represent your intended logical groupings.

const FALSE = 123 - 4 * 10 > 90;      // false
const TRUE = (123 - 4) * 10 > 90;     // true

Closures

If you need more complex logic to initialize your constants you might want to reach for a closure expression.

const TRUE = {
  let lhs = 123 - 4;
  let rhs = 90;
  
  lhs * 10 > rhs;
};  // true

Property Access

When dealing with objects you may need to access their properties which can be done with the . operator.

import { SOME_OBJECT } from "@/constants";

const OBJECT_NAME = SOME_OBJECT.name;

Function Call

Use this syntax to invoke a function and retrieve its result.

func add(lhs: integer, rhs: integer) -> lhs + rhs;

const NUMBER = add(123, 456);    // integer

Last updated