The set Command

Syntax

  set <expression> to <expression>
  set <object literal> on <expression>

Description

The set command allows you to set a value of a variable, property or the DOM. It is similar to the put command but reads more naturally for operations like setting variables.

It can also be used to set many properties at once using the set {...} on form.

Symbol Resolution

When setting a symbol, such as x, the following rules are used:

Note that if you wish to set a global variable you must explicitly use the global modifier unless the symbol starts with a $:

  set global globalVar to 10

Examples

<div _="on click set x to 'foo' then log x">
  Click Me!
</div>

<div _="on click set my.style.color to 'red'">
  Click Me!
</div>

<button _="on click set { disabled: true, innerText: "Don't click me!" } on me">
  Click Me!
</button>