The set Command


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


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


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

<div _="on click set to 'red'">
  Click Me!

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