Mascara Try it Download Buy About Documentation Blog

New Syntax

Apart from the new keywords, there is some new syntactic construct in Mascara JavaScript.

Colon - the colon is used for type annotations, in variable declarations and function signatures. The type is the name after the colon. Type annotations are always optional.

Arrow functions - a shorthand syntax for inline functions (lambdas). Example: x=>x+2

Array comprehensions - an elegant syntax for expressions that operates on lists and arrays. Example: [x*2 for each (x in [1,2,3])]

Destructuring assignments - a very convenient syntax to "unpack" arrays and objects when assigning. Example: [a,b] = [1,2]

Multiline regular expressions - allows more readable regular expressions with whitespace and comments.

Triple quoting - an convenient syntax to have strings spanning multiple lines.

Namespaces adds the double-colon operator.

Trailing commas support prevents a common bug with array- and object literals. Example: [1,2,3,]