There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.Close
Processing...
This may take a few seconds.

var

Syntax

var: (name) (value) [every (time)] [after (time)][, (name)...];

name = The name of the variable to declare or re-assign.

value = The value of the variable. This is written in native JavaScript and must be a JavaScript expression.

The value can be a JavaScript string, number, boolean (true or false), array or object.

JavaScript expressions in the variable value can just be written as straight JavaScript.

Make sure that if you are assigning anything to a variable that converts to a string, such as {@data-myString}, that it is always wrapped in quotes, otherwise it will fail the JavaScript expression evaluation! (eg. var: "{@data-myString}";)

All ACSS variables on the right-hand side of the equation must be typed in their curly brackets and double-quotes if necessary. Note this is a change from version 2.4.0 and this has been implemented to speed up performance by being able to recognise items on the right-hand side quickly as being Active CSS variables.

Eg. taken and tampered with from the Tic Tac Toe example page:

var: player "X",
gameState ['', '', '', '', '', '', '', '', ''],
roundWon false,
roundDraw false,
 bondFilm "mostly all of them" after 1s,
clothes "unsympathetically thrown on with style and cufflinks",
dunnoWhatThisDoes ("{player}" == 'X') ? 'O' : 'X',
winners [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
];
Using ++ or --

From 2.4.0 these operators are supported, so as well as this:

var: count 0;
var: count {count} + 1;
var: count {count} - 1;

you can now also do this:

var: count 0;
var: count++;
var: count--;

See the Regular variables page for more information on their use.