Mascara JavaScript compiler

Try it Download Buy About Documentation Blog Contact

Variable definition

Syntax definition [Help]
var name [ : type ] [ = expression ]
[ , name [ : type ] [ = expression ] ]*

Se also constant.

The rules for variable initialization is stricter in Mascara than in ordinary JavaScript. The stricter rules is there to prevent some common bugs.

A variable have to be declared with var before it can be used.

A variable is only available in the same scope where it is declared with 'var', or in scopes nested inside that scope.

A variable has to be assigned a value before it can be read. The compiler uses definite assignment analysis to ensure that all variables are assigned before use.