How:Write scripts in JavaScript for Memento: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
mNo edit summary
Line 48: Line 48:
:; Constant:a value that has a string (text) value or a numeric (number) value.
:; Constant:a value that has a string (text) value or a numeric (number) value.
<small>
<small>
::; String:"This is a string of textual characters"
::; String literal:"This is a string of textual characters"
::; Number:123 or 3.14 or -28.5
::; String constant: Sol or PlanetMars
::; Symbol:a name representing a constant value, like ''pi'', ''x'', ''tareWeight'', or ''surname''
::; Number literal: 123 or 314e-2 or -28.5
::; Numeric constant: Age or ListPrice
::; Symbol constant:a name representing a constant value, like ''pi'' or ''surname''
</small>
</small>
:; Variable:a name representing a value that may change over time, like ''sum'', ''currentValue'', or ''orderDate''
:; Variable: a name representing a value that may change over time, like ''sum'', ''currentValue'', or ''orderDate''
:; Operator: one or more characters that represent the value of other values that go together in some fashion to determine a result, like '''+''' for ''plus'' or '''-''' for ''minus'' or '''*''' for ''multiplied by'' or '''/''' for ''divided by''.
:; Operator: one or more characters that represent an expression, like '''+''' for ''plus'' or '''-''' for ''minus'' or '''*''' for ''multiplied by'' or '''/''' for ''divided by''.
::Some operators are made up of other operators used in combination, like '''<=''' ''for less than or equal to'' or '''&&''' for ''and also''.
:: Some operators are made up of other operators used in combination, like '''<=''' ''for less than or equal to'' or '''&&''' for ''and also''.


:: in x++, ++ is a ''unary'' operator.
:: in b - 5, - is a ''binary'' operator.
:: in canDrive = age > 16 ? 'yes' : 'no', ? and : are used like if and else together as a ''ternary'' operator &mdash; the ''conditional'' operator. The > is a binary operator that returns ''true'' or ''false''. If the result is true (the age is over 16), then canDrive will be true. If it is false, canDrive will be false. It is good for cases where something is this or else that &mdash; one or the other, plain & simple. Since it is plain & simple, it is (perhaps) appropriate to simplify the conditional as well, with ? and :.


== Trigger script ==
== Trigger script ==

Navigation menu