Mascara: Next Generation JavaScript compiler

Try it Download Buy About Documentation Blog Contact

Built-in Types

Mascara JavaScript has these built-in types:

* (star) - The catch-all type. All values are convertible to the *-type.

Object - The superclass of all classes. Object is also a dynamic type.

int - an integer number. Is not nullable (that is, can be 0 but not null)

float - a floating point number. Is not nullable (that is, can be 0 but not null)

Number - a floating point number. Can also be null.

boolean and Boolean - true or false. Boolean (which capital B) can also be null.

string and String - A string. String (which capital S) can also be null.

Date - A date/time instance.

Array - the generic array type. Arrays can also be more specific, see parameterized types and Array type literals

Function - the generic function type. Function types can also be more specific, see function types

The types starting with a lower case letter are non-nullable. The only difference between string and String is that string is non-nullable. Same with boolean vs. Boolean and float vs. Number.

Literals evaluates to types like this:

A number (eg. 10, -99) has type int

A decimal literal (e.g. 1.5) has type float

A string literal (e.g. "hello") has type string

Literals true and false has type boolean

Object can be replaced by * if the type is unknown, or a structural type if the structure is known.

Additionally there is Math, which is a special case since it cannot be instantiated and cannot be used in type annotations. It works more like a library than a type.

X Try!
Mascara JavaScript Generated JavaScript

Translating...
Show compiler settings